Compare commits

..

1 Commits
cport ... main

Author SHA1 Message Date
25b0d8533e Start implementing I/O for level data. 2023-10-06 19:42:22 -04:00
2 changed files with 12 additions and 136 deletions

View File

@ -1,135 +0,0 @@
/* 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() */

View File

@ -4,13 +4,24 @@
import "CoreLibs/object" import "CoreLibs/object"
import "entity" import "entity"
local yaml = import "lib/lyaml"
local gfx <const> = playdate.graphics local gfx <const> = playdate.graphics
local geom <const> = playdate.geometry local geom <const> = playdate.geometry
class("Wave").extends() class("Wave").extends()
function Wave.new() -- returns a new Wave by loading in and parsing the wave data at path
function Wave.new(path)
local w = Wave() local w = Wave()
local file = io.open(path)
if not file then return nil end
local data = yaml.load(file.read("*a"))
for e in data.entities do
-- tk
end
return w return w
end end