0
\$\begingroup\$

How would you go about making ground correction for a platformer but upside down(reversed gravity)? I used this formula: P.Y+=(P.Y-2)%8-1 but the character just keeps bumping up and down like a pogo stick.

By ground correction I mean checking if the player is inside a solid tile while falling and moving him up (or down in my case) until he isn't.

if pd.dy<0 then
pd.f=true
pd.g=false
pd.j=false
if col_map(pd,"up",1) then pd.f=false pd.dy=0 pd.g=true pd.y+=(pd.y-1)%8
end elseif pd.dy>0 then
pd.j=true
if col_map(pd,"down",1) then pd.dy=0
end end

\$\endgroup\$
3
  • 2
    \$\begingroup\$ I'd recommend showing us this code in the context of where it appears in your program. \$\endgroup\$
    – DMGregory
    Sep 10 '20 at 23:09
  • \$\begingroup\$ if pd.dy<0 then pd.f=true pd.g=false pd.j=false if col_map(pd,"up",1) then pd.f=false pd.dy=0 pd.g=true pd.y+=(pd.y-1)%8 end elseif pd.dy>0 then pd.j=true if col_map(pd,"down",1) then pd.dy=0 end end \$\endgroup\$ Sep 11 '20 at 12:59
  • \$\begingroup\$ You've probably noticed that code doesn't read well in comments. Always use the edit link at the bottom of your question to ensure important information like this is part of your question and formatted correctly, not hidden in a comment. See the help center if you need formatting guidance. \$\endgroup\$
    – DMGregory
    Sep 11 '20 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.