From 4beddb454cce722d31a889145ae4877071bd487e Mon Sep 17 00:00:00 2001 From: kdx Date: Tue, 21 Mar 2023 21:17:54 +0100 Subject: exit direction --- map/weallstartsomewhere.json | 2 +- res/tset.png | Bin 316 -> 305 bytes src/exit.c | 3 ++- src/exit.h | 2 +- src/game.c | 5 ++++- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/map/weallstartsomewhere.json b/map/weallstartsomewhere.json index 7d57dd6..10f4ff3 100644 --- a/map/weallstartsomewhere.json +++ b/map/weallstartsomewhere.json @@ -1 +1 @@ -{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,4,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,5,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,5,1,1,0,2,0,0,0,5,0,0,0,1,1,0,1,1,1,0,0,5,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} \ No newline at end of file +{"width":25,"height":14,"data":[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,3,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,5,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,1,1,1,1,1,0,0,1,0,1,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,0,5,1,1,0,2,0,0,0,5,0,0,0,1,1,0,1,1,1,0,0,5,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]} \ No newline at end of file diff --git a/res/tset.png b/res/tset.png index e751df9..6704f00 100644 Binary files a/res/tset.png and b/res/tset.png differ diff --git a/src/exit.c b/src/exit.c index e1a4909..c6ad4cb 100644 --- a/src/exit.c +++ b/src/exit.c @@ -7,10 +7,11 @@ IMPL_UPDATE() { IMPL_DRAW() { LZY_DrawSetColor(BLACK); rotrect(this->pos[0], this->pos[1], - this->width, this->height, 0.2); + this->width, this->height, 0.2 * this->exit.dir); } IMPL_END IMPL_INIT(exit) { this->width = 12; this->height = 12; + this->exit.dir = 1; } IMPL_END diff --git a/src/exit.h b/src/exit.h index 633fe47..5ea3418 100644 --- a/src/exit.h +++ b/src/exit.h @@ -1,7 +1,7 @@ #pragma once typedef struct { - int _; + int dir; } Exit; struct Entity; diff --git a/src/game.c b/src/game.c index 665363d..62726ca 100644 --- a/src/game.c +++ b/src/game.c @@ -58,12 +58,15 @@ game_restart_scene(Game *this) for (int x = 0; x < map_width(); x++) { const int dx = x * TSIZE + TSIZE / 2; const int dy = y * TSIZE + TSIZE / 2; + Entity *e; switch (map_get(x, y)) { case 2: player_init(game_create_entity(this), dx, dy); break; + case 3: case 4: - exit_init(game_create_entity(this), dx, dy); + e = exit_init(game_create_entity(this), dx, dy); + e->exit.dir = (map_get(x, y) == 3) ? -1 : 1; break; case 5: spike_init(game_create_entity(this), dx, dy); -- cgit v1.2.3