Add Ika weaponry, lots of cleanup, new art assets.

This commit is contained in:
2023-10-01 01:48:06 -04:00
parent 5019be454c
commit e2a30253dd
6 changed files with 65 additions and 39 deletions

View File

@ -5,12 +5,12 @@ import "CoreLibs/sprites"
import "entity"
local gfx <const> = playdate.graphics
local geom <const> = playdate.geometry
class("Ebi").extends(Entity)
function Ebi:init()
local img = gfx.image.new(10, 10, gfx.kColorBlack)
Ebi.super.init(self, img, 5)
Ebi.super.init(self, gfx.image.new("images/ebi.png"), 5)
self:setCollidesWithGroupsMask(0x3)
local dir = 1
@ -18,11 +18,11 @@ function Ebi:init()
dir = -1
end
self.vector = {x=0, y=dir}
self.vector = geom.vector2D.new(0, dir)
self.weaponTimer = playdate.timer.new(2500,
function()
local b = Bullet(2, 1, {x=-1, y=0}, 0x2)
local b = Bullet(2, 1)
b:moveTo(self.x - (self.width/2) - 1, self.y)
b:add()
end
@ -34,7 +34,7 @@ function Ebi:update()
local collisions = Ebi.super.update(self)
for i=1, #collisions, 1 do
if collisions[i].other:getGroupMask() == 0x1 then
self.vector.y *= -1
self.vector.dy *= -1
end
end
end

View File

@ -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