Cleaned collisions.lua, objobjects.lua. Fixed level optimization typo. Added fairy FCS (altitude hold).
This commit is contained in:
@@ -5,9 +5,11 @@ Fairy = Entity:New(x,y)
|
||||
|
||||
-- behaviour
|
||||
o.pos = {x = x, y = y}
|
||||
o.speed = 1
|
||||
o.speed = 1.4
|
||||
o.range = 20
|
||||
o.vision_range = 120
|
||||
o.target = {x = x, y = y}
|
||||
o.hover_distance = 60
|
||||
|
||||
-- animations
|
||||
o.body = Animation:New(animation.fairy.flying)
|
||||
@@ -32,9 +34,30 @@ Fairy = Entity:New(x,y)
|
||||
|
||||
function Fairy:Smart()
|
||||
|
||||
if self:CheckVisionLine(main_Player) then
|
||||
if self:CheckVisionLine(main_Player,self.vision_range) then
|
||||
|
||||
self.target.x = main_Player.pos.x + main_Player.target_offset.x
|
||||
self.target.y = main_Player.pos.y + main_Player.target_offset.y
|
||||
|
||||
local below = 1
|
||||
while not isThereObjectAt(
|
||||
self.target.x,
|
||||
self.target.y + below * game.scale,
|
||||
LoadedObjects.Collisions
|
||||
) do
|
||||
below = below + 1
|
||||
if below >= self.hover_distance then break end
|
||||
end
|
||||
local top = 1
|
||||
while not isThereObjectAt(
|
||||
self.target.x,
|
||||
self.target.y - top * game.scale,
|
||||
LoadedObjects.Collisions
|
||||
) do
|
||||
top = top + 1
|
||||
if top >= self.hover_distance then break end
|
||||
end
|
||||
self.target.y = self.target.y - top + below
|
||||
end
|
||||
|
||||
local distance_x = self.target.x - self.pos.x
|
||||
@@ -55,16 +78,12 @@ function Fairy:Smart()
|
||||
|
||||
local particle_data = {
|
||||
animation = animation.particle.simple,
|
||||
sprite_tint = HEX2RGB("#fe00d1"),
|
||||
sprite_tint = HEX2RGB("#fed100"),
|
||||
direction = angle-math.rad(180+math.random(60)-30),
|
||||
speed = 0.8*(distance/50),
|
||||
speed_increase = -0.01,
|
||||
}
|
||||
Particle:New(
|
||||
self.pos.x,
|
||||
self.pos.y,
|
||||
particle_data
|
||||
)
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -75,17 +94,20 @@ function Fairy:HandleAnimation()
|
||||
end
|
||||
|
||||
function Fairy:DoPhysics()
|
||||
local random_x = math.random(-2, 2)/10
|
||||
local random_y = math.random(-2, 2)/10
|
||||
local random_x = math.random(-4, 4)/10
|
||||
local random_y = math.random(-4, 4)/10
|
||||
|
||||
self.vel.x = self.vel.x + random_x
|
||||
self.vel.y = self.vel.y + random_y
|
||||
-- move
|
||||
|
||||
self:CollisionMove()
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
|
||||
self:LightAdjust()
|
||||
end
|
||||
|
||||
function Fairy:Debug()
|
||||
Entity.Debug(self)
|
||||
self:CheckVisionLineDebug(main_Player)
|
||||
self:CheckVisionLineDebug(main_Player,self.vision_range)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user