Add Ika weaponry, lots of cleanup, new art assets.
This commit is contained in:
parent
5019be454c
commit
e2a30253dd
6 changed files with 65 additions and 39 deletions
|
@ -2,13 +2,33 @@
|
|||
import "CoreLibs/object"
|
||||
import "CoreLibs/graphics"
|
||||
import "CoreLibs/sprites"
|
||||
import "CoreLibs/timer"
|
||||
import "entity"
|
||||
|
||||
local gfx <const> = playdate.graphics
|
||||
local geom <const> = playdate.geometry
|
||||
|
||||
class("Ika").extends(Entity)
|
||||
|
||||
function Ika:init()
|
||||
local img = gfx.image.new(50, 50, gfx.kColorBlack)
|
||||
Ika.super.init(self, img, 25, 1)
|
||||
function Ika:init(target)
|
||||
Ika.super.init(self, gfx.image.new("images/ika.png"), 25, 1)
|
||||
|
||||
self:setCollidesWithGroupsMask(0x2)
|
||||
|
||||
self.weaponTimer = playdate.timer.new(7000,
|
||||
function()
|
||||
local b = Bullet(9, 20, self:calculateVector(target))
|
||||
b:moveTo(self.x - (self.width/2) - 1, self.y)
|
||||
b:add()
|
||||
end
|
||||
)
|
||||
self.weaponTimer.repeats = true
|
||||
end
|
||||
|
||||
function Ika:calculateVector(target)
|
||||
local vec = geom.vector2D.new(0,0)
|
||||
vec.dx = target.x - self.x
|
||||
vec.dy = target.y - self.y
|
||||
|
||||
return vec:normalized() * 3
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue