Created
March 5, 2018 23:16
-
-
Save The0x539/43caf5c07fdac0ccbc8f58eb316eece3 to your computer and use it in GitHub Desktop.
SMBX deceleration logic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if player.speedX ~= 0 then | |
local direction = (player.speedX > 0 and 1 or -1) | |
local amt = 0 | |
local fwd, back = player.rightKeyPressing, player.leftKeyPressing | |
if direction < 0 then | |
fwd, back = back, fwd | |
end | |
local run = player.runKeyPressing | |
local gnd = player:isGroundTouching() | |
local fast = (math.abs(player.speedX) > Defines.player_walkspeed + 0.00001) | |
if gnd and player.downKeyPressing then | |
fwd, back = false, false | |
end | |
if gnd and not fwd then | |
amt = amt + 0.07 | |
end | |
if fast and not run then | |
amt = amt + 0.1 | |
end | |
if back then | |
amt = amt + 0.21 | |
if not gnd then | |
amt = amt + 0.07 | |
end | |
end | |
player.speedX = player.speedX + direction * amt | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment