summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-27 07:43:03 +0200
committerkdx <kikoodx@paranoici.org>2023-03-27 07:43:03 +0200
commiteb7846d195d082578fefb48528c569fa5ef624e3 (patch)
treefcac9171dab69d32abb79412675899adb75f16a9
parent98bc80608f4252fb36bd6d0865341f98b036640b (diff)
download006-eb7846d195d082578fefb48528c569fa5ef624e3.tar.gz
scene previous
-rw-r--r--src/game.c10
-rw-r--r--src/game.h1
-rw-r--r--src/map.c7
-rw-r--r--src/map.h1
4 files changed, 19 insertions, 0 deletions
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);