update cursed book

This commit is contained in:
lustlion 2022-03-11 07:55:55 +01:00
parent cb6623f29a
commit 8c8e4808ad
2 changed files with 19 additions and 15 deletions

View File

@ -22,13 +22,14 @@ function CursedBook:new(x,y)
-- animations
o.body = Animation:new(animation.cursed_book.spawn)
o.body.speed = 0
o.sprite_tint = {0.7,0.7,0.7}
o:centerOffset(o.body)
o:createBox(o.body)
-- light
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()
@ -38,8 +39,10 @@ function CursedBook:new(x,y)
end
function CursedBook:doLogic()
print(self.status)
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 distance_x = self.target.x - self.pos.x
local distance_y = self.target.y - self.pos.y
local angle = getAngleFromVector(distance_x,distance_y)
@ -49,7 +52,7 @@ function CursedBook:doLogic()
if distance < self.spawn_range then
self.status = 1
end
elseif self.status == -1 then
elseif self.status == 2 then
if distance < self.range then
self.vel.x = 0
self.vel.y = 0
@ -59,7 +62,7 @@ function CursedBook:doLogic()
end
elseif self.status == 2 then
if distance < self.attack_range then
self.status = 3
--self.status = 3
end
elseif self.status == 4 then
@ -69,11 +72,12 @@ end
function CursedBook:handleAnimation()
if self.status == 1 then
if self.body.path == "assets/entities/cursed_book/spawn" then
self.body.speed = 1/3
local tint = 0.7 + 0.3 * (self.body.frame-1)/self.body.frames
self.body.speed = 1
local tint = 0.7 + 0.3 * (self.body.frame-1)/#self.body.frames
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.isFlying = true
self.body = self.body:change(animation.cursed_book.flying)
self.sprite_tint = {1,1,1}
--self:getBoundingBox(self.body,2,2,-2,-2)
@ -83,9 +87,9 @@ function CursedBook:handleAnimation()
elseif self.status == 3 then
if self.body.path == "assets/entities/cursed_book/flying" then
self.body = self.body:change(animation.cursed_book.attack_transition)
self.body.speed = 1/3
self:centerOffset(self.body)
if self.body.frame == self.body.frames then
self.body.speed = 1
--self:centerOffset(self.body)
if self.body.frame == #self.body.frames then
self.status = 4
self.body = self.body:change(animation.cursed_book.attack_loop)
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.setColor(1,0,0)
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

View File

@ -35,11 +35,11 @@ animation.cursed_book.flying = {
animation.cursed_book.spawn = {
path = "assets/entities/cursed_book/spawn",
frames = {
0,
0,
0,
0,
0
1/3,
1/3,
1/3,
1/3,
1/3
}
}