From eb7846d195d082578fefb48528c569fa5ef624e3 Mon Sep 17 00:00:00 2001 From: kdx Date: Mon, 27 Mar 2023 07:43:03 +0200 Subject: scene previous --- src/game.c | 10 ++++++++++ src/game.h | 1 + src/map.c | 7 +++++++ src/map.h | 1 + 4 files changed, 19 insertions(+) diff --git a/src/game.c b/src/game.c index fb7994a..6967a3a 100644 --- a/src/game.c +++ b/src/game.c @@ -18,11 +18,21 @@ game_update(Game *this) if (this->queue_next_scene) { if (--this->queue_next_scene == 0) { this->queue_restart_scene = 0; + this->queue_previous_scene = 0; map_next(); game_restart_scene(this); return; } } + if (this->queue_previous_scene) { + if (--this->queue_next_scene == 0) { + this->queue_restart_scene = 0; + this->queue_next_scene = 0; + map_previous(); + game_restart_scene(this); + return; + } + } if (this->queue_restart_scene) { if (--this->queue_restart_scene == 0) game_restart_scene(this); diff --git a/src/game.h b/src/game.h index 2d563f0..6883f76 100644 --- a/src/game.h +++ b/src/game.h @@ -6,6 +6,7 @@ enum { MAX_ENTITIES = 128 }; typedef struct Game { unsigned long uuid; int queue_next_scene; + int queue_previous_scene; int queue_restart_scene; Entity entities[MAX_ENTITIES]; } Game; diff --git a/src/map.c b/src/map.c index e3fc6d2..babb118 100644 --- a/src/map.c +++ b/src/map.c @@ -12,6 +12,13 @@ map_next(void) map_id += 1; } +void +map_previous(void) +{ + if (map_id > 0) + map_id -= 1; +} + int map_width(void) { diff --git a/src/map.h b/src/map.h index 325b3bc..812a100 100644 --- a/src/map.h +++ b/src/map.h @@ -2,6 +2,7 @@ #include "../map/tmj2c.h" void map_next(void); +void map_previous(void); int map_width(void); int map_height(void); int map_get(int x, int y); -- cgit v1.2.3