Add code for repeating waves of enemies, adding intro animations so the enemies can 'fly in', and refactor entity to use a state machine system for more flexibility.
This commit is contained in:
parent
2a2b106df0
commit
001ed4cfa4
8 changed files with 253 additions and 49 deletions
|
@ -12,12 +12,15 @@ class("Ika").extends(Entity)
|
|||
|
||||
function Ika:init(target)
|
||||
Ika.super.init(self, gfx.image.new("images/ika.png"), 25, 1)
|
||||
|
||||
self.target = target
|
||||
self:setCollidesWithGroupsMask(0x2)
|
||||
self.type = 'ika'
|
||||
end
|
||||
|
||||
function Ika:onReady()
|
||||
self.weaponTimer = playdate.timer.new(7000,
|
||||
function()
|
||||
local b = Bullet(9, 20, self:calculateVector(target))
|
||||
local b = Bullet(9, 20, self:calculateVector(self.target))
|
||||
b:moveTo(self.x - (self.width/2) - 1, self.y)
|
||||
b:add()
|
||||
end
|
||||
|
@ -26,9 +29,12 @@ function Ika:init(target)
|
|||
end
|
||||
|
||||
function Ika:calculateVector(target)
|
||||
local vec = geom.vector2D.new(0,0)
|
||||
vec.dx = target.x - self.x
|
||||
vec.dy = target.y - self.y
|
||||
|
||||
local vec = geom.point.new(target:getPosition()) -
|
||||
geom.point.new(self:getPosition())
|
||||
return vec:normalized() * 3
|
||||
end
|
||||
|
||||
function Ika:remove()
|
||||
Ika.super.remove(self)
|
||||
if self.weaponTimer then self.weaponTimer:remove() end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue