Created Particles, added fairy particle, added more entity methods like kill() and entity id
This commit is contained in:
@@ -17,9 +17,11 @@ Fairy = Entity:New(x,y)
|
||||
o.lightRange = 55
|
||||
o.light = CreateLight(o.pos.x,o.pos.y,o.lightRange)
|
||||
|
||||
table.insert(LoadedEntities,o)
|
||||
o.id = #LoadedEntities
|
||||
|
||||
setmetatable(o, self)
|
||||
self.__index = self
|
||||
|
||||
return o
|
||||
end
|
||||
|
||||
@@ -31,8 +33,8 @@ function Fairy:Smart()
|
||||
self.target.y = main_Player.pos.y - main_Player.target_offset.y - 10
|
||||
local distance_x = self.target.x - self.pos.x
|
||||
local distance_y = self.target.y - self.pos.y
|
||||
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
|
||||
local angle = GetAngleFromVector(distance_x,distance_y)
|
||||
local distance = math.sqrt(distance_x ^ 2 + distance_y ^ 2)
|
||||
if distance < self.range then
|
||||
self.vel.x = 0
|
||||
self.vel.y = 0
|
||||
@@ -40,6 +42,7 @@ function Fairy:Smart()
|
||||
self.vel.x = math.cos(angle)*self.speed*distance/(8*game.scale)
|
||||
self.vel.y = math.sin(angle)*self.speed*distance/(8*game.scale)
|
||||
end
|
||||
Particle:New(self.pos.x,self.pos.y,animation.particle.fairy,angle-math.rad(180),self.speed*distance/(16*game.scale))
|
||||
end
|
||||
|
||||
function Fairy:HandleAnimation()
|
||||
|
||||
Reference in New Issue
Block a user