This commit is contained in:
@@ -2,7 +2,7 @@ Arrow = Entity:New(x,y)
|
||||
|
||||
function Arrow:New(x,y,rotation,speed)
|
||||
local o = Entity:New(x,y)
|
||||
|
||||
arrow = arrow + 1
|
||||
o.pos = {x = x, y = y}
|
||||
o.speed = speed or 0
|
||||
o.sprite_rotation = rotation or 0
|
||||
@@ -32,45 +32,47 @@ function Arrow:HandleAnimation()
|
||||
end
|
||||
|
||||
function Arrow:DoPhysics()
|
||||
-- horizontal collisions
|
||||
if not isThereAnyCollisionAt(
|
||||
self.pos.x + self.vel.x,
|
||||
self.pos.y
|
||||
) then
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
else
|
||||
while not isThereObjectAt(
|
||||
self.pos.x + math.sign(self.vel.x),
|
||||
self.pos.y,
|
||||
objects.collisions
|
||||
) do
|
||||
self.pos.x = self.pos.x + math.sign(self.vel.x)
|
||||
if not self.stuck then
|
||||
-- horizontal collisions
|
||||
if not isThereAnyCollisionAt(
|
||||
self.pos.x + self.vel.x,
|
||||
self.pos.y
|
||||
) then
|
||||
self.pos.x = self.pos.x + self.vel.x
|
||||
else
|
||||
while not isThereObjectAt(
|
||||
self.pos.x + math.sign(self.vel.x),
|
||||
self.pos.y,
|
||||
objects.collisions
|
||||
) do
|
||||
self.pos.x = self.pos.x + math.sign(self.vel.x)
|
||||
end
|
||||
self.stuck = true
|
||||
end
|
||||
self.stuck = true
|
||||
end
|
||||
-- vertical collision
|
||||
if not isThereAnyCollisionAt(
|
||||
self.pos.x,
|
||||
self.pos.y + self.vel.y
|
||||
) then
|
||||
self.pos.y = self.pos.y + self.vel.y
|
||||
else
|
||||
while not isThereObjectAt(
|
||||
-- vertical collision
|
||||
if not isThereAnyCollisionAt(
|
||||
self.pos.x,
|
||||
self.pos.y + math.sign(self.vel.y),
|
||||
objects.collisions
|
||||
) do
|
||||
self.pos.y = self.pos.y + math.sign(self.vel.y)
|
||||
self.pos.y + self.vel.y
|
||||
) then
|
||||
self.pos.y = self.pos.y + self.vel.y
|
||||
else
|
||||
while not isThereObjectAt(
|
||||
self.pos.x,
|
||||
self.pos.y + math.sign(self.vel.y),
|
||||
objects.collisions
|
||||
) do
|
||||
self.pos.y = self.pos.y + math.sign(self.vel.y)
|
||||
end
|
||||
self.stuck = true
|
||||
end
|
||||
-- stuck into collisions
|
||||
if self.stuck then
|
||||
--lets allow the arrow to tip a bit into the thing
|
||||
self.pos.x = self.pos.x + self.vel.x / 5
|
||||
self.pos.y = self.pos.y + self.vel.y / 5
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
self.illuminated = false
|
||||
end
|
||||
self.stuck = true
|
||||
end
|
||||
-- stuck into collisions
|
||||
if self.stuck then
|
||||
--lets allow the arrow to tip a bit into the thing
|
||||
self.pos.x = self.pos.x + self.vel.x / 5
|
||||
self.pos.y = self.pos.y + self.vel.y / 5
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
self.illuminated = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -50,8 +50,8 @@ end
|
||||
|
||||
function Fairy:DoPhysics()
|
||||
|
||||
local random_x = math.random(-0.04,0.04)
|
||||
local random_y = math.random(-0.04,0.04)
|
||||
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
|
||||
-- move
|
||||
|
||||
@@ -69,9 +69,9 @@ function Kupo:Smart()
|
||||
self.bow_rotation = angle
|
||||
end
|
||||
|
||||
-- holding tight dispersion -- also affets arrows
|
||||
-- holding tight dispersion -- also affects arrows
|
||||
if self.bow_rotation == angle then
|
||||
self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2))
|
||||
self.bow_rotation = self.bow_rotation + math.rad(math.random(math.abs(math.floor(self.bow_frame-self.bow_aim_frames-self.bow_frames)/2)))
|
||||
end
|
||||
|
||||
-- AIMING AI
|
||||
|
||||
Reference in New Issue
Block a user