editor progress, generic keybinds, player coyote value, cursed book entity, level changes, camera adjustments
This commit is contained in:
@@ -3,6 +3,7 @@ Fairy = Entity:New(x,y)
|
||||
function Fairy:New(x,y)
|
||||
local o = Entity:New(x,y)
|
||||
|
||||
-- behaviour
|
||||
o.pos = {x = x, y = y}
|
||||
o.speed = 0.23
|
||||
o.range = 20
|
||||
@@ -13,9 +14,13 @@ Fairy = Entity:New(x,y)
|
||||
o:centerOffset(o.body)
|
||||
o:getBoundingBox(o.body)
|
||||
|
||||
-- light
|
||||
o.light_range = 80
|
||||
o.light = CreateLight(o.pos.x,o.pos.y,o.light_range,nil,HEX2RGB("#fed100"))
|
||||
|
||||
o.lightRange = 0
|
||||
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
|
||||
-- timer
|
||||
o.particle_timer = 0
|
||||
o.particle_time = 5
|
||||
|
||||
table.insert(LoadedEntities,o)
|
||||
o.id = #LoadedEntities
|
||||
@@ -26,8 +31,6 @@ Fairy = Entity:New(x,y)
|
||||
end
|
||||
|
||||
function Fairy:Smart()
|
||||
self.light.pos.x = self.pos.x-self.target_offset.x
|
||||
self.light.pos.y = self.pos.y-self.target_offset.y
|
||||
|
||||
self.target.x = main_Player.pos.x - main_Player.target_offset.x
|
||||
self.target.y = main_Player.pos.y - main_Player.target_offset.y - 10
|
||||
@@ -39,18 +42,27 @@ function Fairy:Smart()
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
else
|
||||
self.vel.x = math.cos(angle)*self.speed*distance/(8*game.scale)
|
||||
self.vel.y = math.sin(angle)*self.speed*distance/(8*game.scale)
|
||||
self.vel.x = math.cos(angle)*self.speed*distance/8
|
||||
self.vel.y = math.sin(angle)*self.speed*distance/8
|
||||
|
||||
end
|
||||
self.particle_timer = self.particle_timer + 1
|
||||
if self.particle_timer >= self.particle_time then
|
||||
self.particle_timer = 0
|
||||
|
||||
local particle_data = {
|
||||
animation = animation.particle.fairy,
|
||||
direction = angle-math.rad(180),
|
||||
speed = self.speed*distance/(16*game.scale),
|
||||
light = 85
|
||||
}
|
||||
|
||||
Particle:New(self.pos.x,self.pos.y,particle_data)
|
||||
local particle_data = {
|
||||
animation = animation.particle.simple,
|
||||
sprite_tint = HEX2RGB("#fe00d1"),
|
||||
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
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function Fairy:HandleAnimation()
|
||||
@@ -60,11 +72,12 @@ function Fairy:HandleAnimation()
|
||||
end
|
||||
|
||||
function Fairy:DoPhysics()
|
||||
|
||||
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
|
||||
|
||||
self:CollisionMove()
|
||||
self:LightAdjust()
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user