mirror of
https://github.com/libretro/lutro-platformer.git
synced 2024-11-23 16:19:46 +00:00
Add max yspeed
This commit is contained in:
parent
1d373461a8
commit
f404c68d73
@ -12,6 +12,7 @@ function newNinja(object)
|
||||
n.xaccel = 900
|
||||
n.yaccel = 600
|
||||
n.max_xspeed = 150
|
||||
n.max_yspeed = 280
|
||||
n.friction = 20
|
||||
n.groundfriction = 20
|
||||
n.airfriction = 2
|
||||
@ -122,6 +123,7 @@ function ninja:update(dt)
|
||||
-- gravity
|
||||
if not on_the_ground then
|
||||
self.yspeed = self.yspeed + self.yaccel * dt
|
||||
self.yspeed = math.min(self.yspeed, self.max_yspeed)
|
||||
self.y = self.y + dt * self.yspeed
|
||||
end
|
||||
|
||||
@ -183,8 +185,7 @@ function ninja:update(dt)
|
||||
-- decelerating
|
||||
self.friction = on_the_ground and self.groundfriction or self.airfriction
|
||||
|
||||
if not (JOY_RIGHT and self.xspeed > 0)
|
||||
and not (JOY_LEFT and self.xspeed < 0)
|
||||
if not JOY_RIGHT and not JOY_LEFT
|
||||
then
|
||||
if self.xspeed > 0 then
|
||||
self.xspeed = self.xspeed - self.friction
|
||||
|
Loading…
Reference in New Issue
Block a user