diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..cca971a --- /dev/null +++ b/src/main.c @@ -0,0 +1,135 @@ +/* Collision groups: */ +/* 0x1 - top and bottom walls */ +/* 0x2 - player */ +/* 0x4 - enemies */ +/* 0x8 - side walls */ +/* 0x10 - bullets */ + +#include "pd_api.h" + +#include "kani.h" +#include "enemies.h" +#include "wave.h" + +/* local player = nil */ +/* local ui = nil */ +/* local currentWave = nil */ + +/* function playdate.update() */ +/* gfx.sprite.update() */ +/* if currentWave:update() then */ +/* -- fight forever lol */ +/* currentWave = newWave() */ +/* playdate.timer.performAfterDelay(1000, Wave.add, currentWave) */ +/* end */ +/* playdate.timer.updateTimers() */ +/* end */ + +Kani* player = NULL; +UI* ui = NULL; +Wave* currentWave = NULL; + +int update(void* userdata) { + PlaydateAPI* pd = userdata; + + pd->sprite->updateAndDrawSprites(); + + if (currentWave->update()) { + currentWave = newWave(pd); // TODO: this is a stub that just repeats the same wave over and over + currentWave->add(); + } +} + +int eventHandler(PlaydateAPI* pd, PDSystemEvent event, uint32_t arg) { + if (event == kEventInit) { + pd->system->setUpdateCallback(update, pd); + + currentWave = newWave(); // TODO: this is a stub that just repeats the same wave over and over + currentWave->add(); + + ui = newUI(pd); + player = newKani(pd); + } +} + +Wave* newWave() { + +} + +/* function setup() */ +/* ui = UI() */ +/* player = Kani(ui) */ +/* player:moveTo(16, 120) */ +/* player:add() */ +/* ui:add() */ + +/* makeWalls() */ +/* drawBackground() */ +/* end */ + +/* function makeWalls() */ +/* makeWall(200, 0, 400, 1, 0x1) */ +/* makeWall(0, 120, 1, 240, 0x8) */ +/* makeWall(200, 240, 400, 1, 0x1) */ +/* makeWall(400, 120, 1, 240, 0x8) */ +/* end */ + +/* function makeWall(x, y, w, h, mask) */ +/* local wall = gfx.sprite.new() */ +/* wall:setSize(w, h) */ +/* wall:setCollideRect(0, 0, wall:getSize()) */ +/* wall:moveTo(x, y) */ +/* wall:setGroupMask(mask) */ +/* wall:add() */ +/* end */ + +/* function drawBackground() */ +/* local backgroundImage = gfx.image.new(400, 240, gfx.kColorWhite) */ +/* gfx.sprite.setBackgroundDrawingCallback( */ +/* function(x, y, width, height) */ +/* backgroundImage:draw(0, 0) */ +/* end */ +/* ) */ +/* 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( */ +/* 5000, */ +/* 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( */ +/* 2500, */ +/* startPosition, */ +/* geom.point.new(x,y) */ +/* ) */ + +/* wave:addEntity(enemy) */ + +/* y += 50 */ +/* end */ + +/* return wave */ +/* end */ + + +/* setup() */