After putting in a framerate counter, I noticed something strange. My FPS was constantly around 999 even though I've read that Love only goes up to 60. I then tried to isolate the problem further by closing all of my other programs, including Firefox and other RAM-heavy programs. After I did that, I think I went through what my testers did and noticed that the friction was way too slippery, leading me to believe that it is a framerate-related issue that causes my friction system to not work.
My code is admittedly a mess, but everything except for the friction works fine. Here's the friction code itself:
Code: Select all
Player.vel = Player.vel - Player.friction
if Player.dir == 'r' then
Player.x = Player.x + Player.vel * dt
elseif Player.dir == 'l' then
Player.x = Player.x - Player.vel * dt
end
if love.keyboard.isDown('right') and
love.keyboard.isDown('left')==false
then
if (Player.vel > 0 and Player.dir == 'l') then
Player.vel = Player.vel - Player.friction
Player.x = Player.x - Player.vel * dt
elseif Player.vel == 0 then
Player.dir = 'r'
end
Player.vel = Player.vel + Player.friction
Player.x = Player.x + Player.vel * dt
end
if love.keyboard.isDown('left') and
love.keyboard.isDown('right')==false and
Player.crouch == false
then
if (Player.vel > 0 and Player.dir == 'r') then
Player.vel = Player.vel - Player.friction
Player.x = Player.x + Player.vel * dt
elseif Player.vel == 0 then
Player.dir = 'l'
end
Player.vel = Player.vel + Player.friction
Player.x = Player.x - Player.vel * dt
end
Code: Select all
dt = math.min(dt, 1/60)