Back to shtanton's homepage
summaryrefslogtreecommitdiff
path: root/src/all.c
diff options
context:
space:
mode:
authorCharlie Stanton <charlie@shtanton.xyz>2025-04-07 18:53:49 +0100
committerCharlie Stanton <charlie@shtanton.xyz>2025-04-07 18:53:49 +0100
commitd0863cbc9e6276776eecfbdab3f95e3bf33cfeef (patch)
tree0a542b8f4d6cfc31954b61d1fee818c0599a3fbc /src/all.c
parentbd31dd79eb31b76f3d7276be8dfaff21f615b1da (diff)
downloadldjam57-main.tar
polishHEADmain
Diffstat (limited to 'src/all.c')
-rw-r--r--src/all.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/all.c b/src/all.c
index b118a16..cf52eca 100644
--- a/src/all.c
+++ b/src/all.c
@@ -390,8 +390,10 @@ static void restart_level(Game* game) {
xmemcpy(&game->state.placeableCells, &levels[level].placeableCells, sizeof(game->state.placeableCells));
}
-static void update(Game *game, uint64_t now, Arena a) {
+static int update(Game *game, uint64_t now, Arena a) {
const int offset_width = game->ui.width - GRID_OFFSET_X;
+
+ int tutorial = 0;
switch (game->input) {
int x, y;
@@ -451,6 +453,7 @@ static void update(Game *game, uint64_t now, Arena a) {
restart_level(game);
break;
case BUTTON_BACK:
+ tutorial = 1;
break;
case BUTTON_PLAY:
game->state.playing = !game->state.playing;
@@ -495,6 +498,8 @@ static void update(Game *game, uint64_t now, Arena a) {
tick(game, a);
}
+
+ return tutorial;
}
#if SDL
@@ -677,10 +682,12 @@ void game_init(void) {
perm.end = heap + MEM_SIZE;
game = new(&perm, 1, Game);
- xmemcpy(&game->state.grid, &levels[0].grid, sizeof(game->state.grid));
- game->state.goalx = levels[0].goalx;
- game->state.goaly = levels[0].goaly;
- game->state.playing = 0;
+ game->state.currentLevel = 0;
+ restart_level(game);
+
+ for (int i = 0; i < N_BUTTONS; i++) {
+ game->state.buttonStates[i] = BUTTON_STATE_IDLE;
+ }
}
__attribute((export_name("game_render")))
@@ -694,11 +701,11 @@ DrawList *game_render(int width, int height, int mousex, int mousey) {
}
__attribute((export_name("game_update")))
-void game_update(int input, int mousex, int mousey, int now) {
+int game_update(int input, int mousex, int mousey, int now) {
game->input = input;
game->ui.mousex = mousex;
game->ui.mousey = mousey;
- update(game, now, perm);
+ return update(game, now, perm);
}
#endif