function to improve entities moving on collisions and fixed accordingly
made math.round() changed vector() and fixed accordingly
This commit is contained in:
@@ -67,6 +67,13 @@ function CursedBook:doLogic()
|
||||
elseif self.status == 4 then
|
||||
|
||||
end
|
||||
|
||||
if self.isFlying then
|
||||
local random_x = math.random(-4, 4)/100
|
||||
local random_y = math.random(-4, 4)/100
|
||||
self.vel.x = self.vel.x + random_x
|
||||
self.vel.y = self.vel.y + random_y
|
||||
end
|
||||
end
|
||||
|
||||
function CursedBook:handleAnimation()
|
||||
@@ -101,15 +108,21 @@ function CursedBook:handleAnimation()
|
||||
end
|
||||
|
||||
function CursedBook:doPhysics()
|
||||
if self.isFlying then
|
||||
local random_x = math.random(-4, 4)/100
|
||||
local random_y = math.random(-4, 4)/100
|
||||
self.vel.x = self.vel.x + random_x
|
||||
self.vel.y = self.vel.y + random_y
|
||||
end
|
||||
-- move
|
||||
|
||||
self:moveWithCollision()
|
||||
-- horizontal collision
|
||||
self:moveX(
|
||||
self.vel.x,
|
||||
function()
|
||||
self.vel.x = 0
|
||||
end
|
||||
)
|
||||
-- vertical collision
|
||||
self:moveY(
|
||||
self.vel.y,
|
||||
function()
|
||||
self.vel.y = 0
|
||||
end
|
||||
)
|
||||
-- final position
|
||||
self:adjustLight()
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user