refactor(levels): use the friction system from gamecore
This commit is contained in:
parent
0da137a3e4
commit
c21753d988
|
@ -10,7 +10,7 @@ function Debris:new(world, x, y, speed, dir, timelimit)
|
|||
self:setMotionDirection(dir, speed)
|
||||
self.grav = 1
|
||||
self:setBounceFactor(0.5)
|
||||
self.frc = 0.046875*60*1.5
|
||||
self.xfrc = 0.046875*60*1.5*60*4
|
||||
self.rotation = love.math.random(0, 360)
|
||||
end
|
||||
|
||||
|
@ -27,7 +27,7 @@ end
|
|||
function Debris:update(dt)
|
||||
self:setFilter()
|
||||
self:gravity(dt)
|
||||
self:friction(dt)
|
||||
self:applyFriction(dt)
|
||||
|
||||
--self.x, self.y, cols, cols_len = currentLevel.world:move(self, self.x + self.xsp*dt, self.y + self.ysp*dt, bulletFilter)
|
||||
cols, cols_len = self:move(dt)
|
||||
|
|
|
@ -7,11 +7,6 @@ function Entity:new(world, type, x, y, w, h, isSolid)
|
|||
Entity.super.new(self, world, type, x, y, w, h, isSolid)
|
||||
end
|
||||
|
||||
function Entity:initMovement()
|
||||
Entity.super.initMovement(self)
|
||||
self.frc = 0
|
||||
end
|
||||
|
||||
function Entity:initGravity()
|
||||
self.grav = 0
|
||||
self.gacc = 550
|
||||
|
@ -43,12 +38,9 @@ function Entity:gravity(dt)
|
|||
self.ysp = self.ysp + self.gacc * self.grav * dt
|
||||
end
|
||||
|
||||
function Entity:friction(dt)
|
||||
if (math.abs(self.xsp) <= self.frc) then
|
||||
self.xsp = 0
|
||||
else
|
||||
self.xsp = self.xsp - (self.frc * utils.math.sign(self.xsp))
|
||||
end
|
||||
function Entity:applyFriction(dt)
|
||||
self.xsp = utils.math.toZero(self.xsp, self.xfrc * dt)
|
||||
self.ysp = utils.math.toZero(self.ysp, self.yfrc * dt)
|
||||
end
|
||||
|
||||
function Entity:purge()
|
||||
|
|
|
@ -49,7 +49,7 @@ function Player:initStats()
|
|||
self.topsp = 4.5*60
|
||||
self.acc = 0.046875*60*1.5
|
||||
self.dec = 0.5*60
|
||||
self.frc = self.acc
|
||||
self.xfrc = self.acc*60*4
|
||||
self.grav = 1
|
||||
self.jmp = -5*60
|
||||
|
||||
|
@ -156,7 +156,7 @@ function Player:actionMove(dt)
|
|||
end
|
||||
end
|
||||
else
|
||||
self:friction(dt)
|
||||
self:applyFriction(dt)
|
||||
end
|
||||
|
||||
if (self.grav == 0) then
|
||||
|
|
Loading…
Reference in New Issue