function to improve entities moving on collisions and fixed accordingly
made math.round() changed vector() and fixed accordingly
This commit is contained in:
@@ -89,26 +89,32 @@ function Particle:handleAnimation()
|
||||
end
|
||||
end
|
||||
|
||||
function Particle:doPhysics()
|
||||
function Particle:doLogic()
|
||||
-- adjust speed
|
||||
if self.speed_increase ~= 0 then
|
||||
self.speed = self.speed + self.speed_increase
|
||||
self.vel.x = self.speed * math.cos(self.direction)
|
||||
self.vel.y = self.speed * math.sin(self.direction)
|
||||
end
|
||||
-- move
|
||||
self:moveWithCollision()
|
||||
|
||||
if self.light ~= nil then
|
||||
self:adjustLight()
|
||||
self.light.range = self.light_range * self.sprite_alpha/2
|
||||
end
|
||||
|
||||
if self.time ~= nil then
|
||||
if self.timer >= self.time then self:kill() end
|
||||
end
|
||||
end
|
||||
|
||||
function Particle:doPhysics()
|
||||
-- horizontal collision
|
||||
self:moveX(
|
||||
self.vel.x
|
||||
)
|
||||
-- vertical collision
|
||||
self:moveY(
|
||||
self.vel.y
|
||||
)
|
||||
-- final position
|
||||
self:adjustLight()
|
||||
end
|
||||
|
||||
function Particle:debug()
|
||||
-- draw center CYAN
|
||||
love.graphics.setColor(0,1,1)
|
||||
|
||||
Reference in New Issue
Block a user