function to improve entities moving on collisions and fixed accordingly

made math.round()
changed vector() and fixed accordingly
This commit is contained in:
lustlion
2022-03-16 18:50:10 +01:00
parent 4d94cc805d
commit 236e23177d
9 changed files with 189 additions and 113 deletions

View File

@@ -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)