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:
Anna Rose Wiggins 2023-10-03 16:16:19 -04:00
parent 2a2b106df0
commit 001ed4cfa4
8 changed files with 253 additions and 49 deletions

View file

@ -9,13 +9,15 @@ import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"
import "kani"
import "enemy/ika"
import "enemy/ebi"
import "enemies"
import "wave"
local gfx <const> = playdate.graphics
local geom <const> = playdate.geometry
local player = nil
local ui = nil
local currentWave = nil
function setup()
ui = UI()
@ -24,26 +26,8 @@ function setup()
player:addInputHandlers()
player:add()
ui:add()
local enemy = Ika(player)
enemy:moveTo(350, 120)
enemy:add()
-- enemy = Ebi()
-- enemy:moveTo(270, 50)
-- enemy:add()
-- enemy = Ebi()
-- enemy:moveTo(280, 100)
-- enemy:add()
-- enemy = Ebi()
-- enemy:moveTo(290, 150)
-- enemy:add()
-- enemy = Ebi()
-- enemy:moveTo(300, 200)
-- enemy:add()
currentWave = newWave()
currentWave:add()
makeWalls()
drawBackground()
@ -81,8 +65,52 @@ function drawBackground()
)
end
-- Right now we only have a single wave and we repeat it forever
function newWave()
wave = Wave.new()
local startPosition = geom.point.new(410,120)
local enemy = Ika(player)
enemy.introAnimator = gfx.animator.new(
10000,
startPosition,
geom.point.new(350,120)
)
wave:addEntity(enemy)
local y = 50
for x=270, 300, 10 do
local dir = 1
if math.random(2) == 1 then
dir = -1
end
local vector = geom.vector2D.new(0, dir)
enemy = Ebi()
enemy.vector = vector
enemy.introAnimator = gfx.animator.new(
5000,
startPosition,
geom.point.new(x,y)
)
wave:addEntity(enemy)
y += 50
end
return wave
end
function playdate.update()
gfx.sprite.update()
if currentWave:update() then
-- fight forever lol
currentWave = newWave()
currentWave:add()
end
playdate.timer.updateTimers()
end