update cursed book
This commit is contained in:
parent
cb6623f29a
commit
8c8e4808ad
@ -22,13 +22,14 @@ function CursedBook:new(x,y)
|
|||||||
|
|
||||||
-- animations
|
-- animations
|
||||||
o.body = Animation:new(animation.cursed_book.spawn)
|
o.body = Animation:new(animation.cursed_book.spawn)
|
||||||
|
o.body.speed = 0
|
||||||
o.sprite_tint = {0.7,0.7,0.7}
|
o.sprite_tint = {0.7,0.7,0.7}
|
||||||
o:centerOffset(o.body)
|
o:centerOffset(o.body)
|
||||||
o:createBox(o.body)
|
o:createBox(o.body)
|
||||||
|
|
||||||
-- light
|
-- light
|
||||||
o.light_range = 500
|
o.light_range = 500
|
||||||
o.light = Light:new(o.pos.x,o.pos.y,o.light_range,2,hex2rgb("#fe00d1"))
|
--o.light = Light:new(o.pos.x,o.pos.y,o.light_range,2,hex2rgb("#fe00d1"))
|
||||||
|
|
||||||
o:id()
|
o:id()
|
||||||
|
|
||||||
@ -38,8 +39,10 @@ function CursedBook:new(x,y)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function CursedBook:doLogic()
|
function CursedBook:doLogic()
|
||||||
|
print(self.status)
|
||||||
self.target.x = main_player.pos.x - main_player.target_offset.x
|
self.target.x = main_player.pos.x - main_player.target_offset.x
|
||||||
self.target.y = main_player.pos.y - main_player.target_offset.y
|
self.target.y = main_player.pos.y - main_player.target_offset.y
|
||||||
|
|
||||||
local distance_x = self.target.x - self.pos.x
|
local distance_x = self.target.x - self.pos.x
|
||||||
local distance_y = self.target.y - self.pos.y
|
local distance_y = self.target.y - self.pos.y
|
||||||
local angle = getAngleFromVector(distance_x,distance_y)
|
local angle = getAngleFromVector(distance_x,distance_y)
|
||||||
@ -49,7 +52,7 @@ function CursedBook:doLogic()
|
|||||||
if distance < self.spawn_range then
|
if distance < self.spawn_range then
|
||||||
self.status = 1
|
self.status = 1
|
||||||
end
|
end
|
||||||
elseif self.status == -1 then
|
elseif self.status == 2 then
|
||||||
if distance < self.range then
|
if distance < self.range then
|
||||||
self.vel.x = 0
|
self.vel.x = 0
|
||||||
self.vel.y = 0
|
self.vel.y = 0
|
||||||
@ -59,7 +62,7 @@ function CursedBook:doLogic()
|
|||||||
end
|
end
|
||||||
elseif self.status == 2 then
|
elseif self.status == 2 then
|
||||||
if distance < self.attack_range then
|
if distance < self.attack_range then
|
||||||
self.status = 3
|
--self.status = 3
|
||||||
end
|
end
|
||||||
elseif self.status == 4 then
|
elseif self.status == 4 then
|
||||||
|
|
||||||
@ -69,11 +72,12 @@ end
|
|||||||
function CursedBook:handleAnimation()
|
function CursedBook:handleAnimation()
|
||||||
if self.status == 1 then
|
if self.status == 1 then
|
||||||
if self.body.path == "assets/entities/cursed_book/spawn" then
|
if self.body.path == "assets/entities/cursed_book/spawn" then
|
||||||
self.body.speed = 1/3
|
self.body.speed = 1
|
||||||
local tint = 0.7 + 0.3 * (self.body.frame-1)/self.body.frames
|
local tint = 0.7 + 0.3 * (self.body.frame-1)/#self.body.frames
|
||||||
self.sprite_tint = {tint,tint,tint}
|
self.sprite_tint = {tint,tint,tint}
|
||||||
if self.body.frame == self.body.frames then
|
if self.body.frame == #self.body.frames then
|
||||||
self.status = 2
|
self.status = 2
|
||||||
|
self.isFlying = true
|
||||||
self.body = self.body:change(animation.cursed_book.flying)
|
self.body = self.body:change(animation.cursed_book.flying)
|
||||||
self.sprite_tint = {1,1,1}
|
self.sprite_tint = {1,1,1}
|
||||||
--self:getBoundingBox(self.body,2,2,-2,-2)
|
--self:getBoundingBox(self.body,2,2,-2,-2)
|
||||||
@ -83,9 +87,9 @@ function CursedBook:handleAnimation()
|
|||||||
elseif self.status == 3 then
|
elseif self.status == 3 then
|
||||||
if self.body.path == "assets/entities/cursed_book/flying" then
|
if self.body.path == "assets/entities/cursed_book/flying" then
|
||||||
self.body = self.body:change(animation.cursed_book.attack_transition)
|
self.body = self.body:change(animation.cursed_book.attack_transition)
|
||||||
self.body.speed = 1/3
|
self.body.speed = 1
|
||||||
self:centerOffset(self.body)
|
--self:centerOffset(self.body)
|
||||||
if self.body.frame == self.body.frames then
|
if self.body.frame == #self.body.frames then
|
||||||
self.status = 4
|
self.status = 4
|
||||||
self.body = self.body:change(animation.cursed_book.attack_loop)
|
self.body = self.body:change(animation.cursed_book.attack_loop)
|
||||||
self:centerOffset(self.body)
|
self:centerOffset(self.body)
|
||||||
@ -115,5 +119,5 @@ function CursedBook:debug()
|
|||||||
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.spawn_range)
|
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.spawn_range)
|
||||||
love.graphics.setColor(1,0,0)
|
love.graphics.setColor(1,0,0)
|
||||||
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.attack_range)
|
love.graphics.circle("line", -Camera.pos.x + self.pos.x, -Camera.pos.y + self.pos.y, self.attack_range)
|
||||||
Entity.Debug(self)
|
Entity.debug(self)
|
||||||
end
|
end
|
||||||
|
@ -35,11 +35,11 @@ animation.cursed_book.flying = {
|
|||||||
animation.cursed_book.spawn = {
|
animation.cursed_book.spawn = {
|
||||||
path = "assets/entities/cursed_book/spawn",
|
path = "assets/entities/cursed_book/spawn",
|
||||||
frames = {
|
frames = {
|
||||||
0,
|
1/3,
|
||||||
0,
|
1/3,
|
||||||
0,
|
1/3,
|
||||||
0,
|
1/3,
|
||||||
0
|
1/3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user