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
    Commented Sep 10, 2020 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\$ Commented Sep 11, 2020 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
    Commented Sep 11, 2020 at 13:02

0

You must log in to answer this question.

Browse other questions tagged .