summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-21 21:29:20 +0100
committerkdx <kikoodx@paranoici.org>2023-03-21 21:29:20 +0100
commita262d351465957eadba265f1c3976e202e5b768d (patch)
tree86656c0aa774ea09e591259c76556c19b9e7154b
parent4beddb454cce722d31a889145ae4877071bd487e (diff)
downloadhyperultra-a262d351465957eadba265f1c3976e202e5b768d.tar.gz
hope this doesn't lag
-rw-r--r--map/wakywakysnakysnake.json2
-rw-r--r--src/game.c14
-rw-r--r--src/game.h2
3 files changed, 16 insertions, 2 deletions
diff --git a/map/wakywakysnakysnake.json b/map/wakywakysnakysnake.json
index e2fbf09..d2c8e00 100644
--- a/map/wakywakysnakysnake.json
+++ b/map/wakywakysnakysnake.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,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,5,0,0,0,1,1,1,1,5,0,0,0,0,0,0,0,0,2,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,5,0,0,0,0,0,4,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,5,0,0,1,1,1,1,1,1,1,5,0,0,0,0,0,5,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,5,1,1,5,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,0,0,5,0,0,1,1,0,5,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,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,1,1,1,1,1,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,5,0,0,0,1,1,1,1,5,0,0,0,0,0,0,0,2,0,0,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,5,0,0,0,0,0,4,1,1,1,1,1,1,0,0,5,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,5,0,0,1,1,1,1,1,1,1,5,0,0,0,0,0,5,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,1,0,0,5,1,1,5,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,5,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,5,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,5,0,0,5,0,0,1,1,0,5,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,1,1,1,1,1,1,1]} \ No newline at end of file
diff --git a/src/game.c b/src/game.c
index 62726ca..877385a 100644
--- a/src/game.c
+++ b/src/game.c
@@ -10,6 +10,7 @@ void
game_init(Game *this)
{
memset(this, 0, sizeof(*this));
+ this->player_dir = 1;
game_restart_scene(this);
}
@@ -28,6 +29,7 @@ game_update(Game *this)
}
if (this->queue_next_scene) {
this->queue_next_scene = false;
+ this->player_dir = game_get_entity(this, ET_exit)->exit.dir;
map_next();
game_restart_scene(this);
return;
@@ -61,7 +63,8 @@ game_restart_scene(Game *this)
Entity *e;
switch (map_get(x, y)) {
case 2:
- player_init(game_create_entity(this), dx, dy);
+ e = player_init(game_create_entity(this), dx, dy);
+ e->player.dirx = this->player_dir;
break;
case 3:
case 4:
@@ -100,3 +103,12 @@ game_entity_count(Game *this, unsigned int type)
count += (this->entities[i].type == type);
return count;
}
+
+Entity *
+game_get_entity(Game *this, unsigned int type)
+{
+ for (int i = 0; i < MAX_ENTITIES; i++)
+ if (this->entities[i].type == type)
+ return &this->entities[i];
+ return NULL;
+}
diff --git a/src/game.h b/src/game.h
index ebb5c09..001d467 100644
--- a/src/game.h
+++ b/src/game.h
@@ -7,6 +7,7 @@ typedef struct Game {
unsigned int uuid;
bool queue_next_scene;
int queue_restart_scene;
+ int player_dir;
Entity entities[MAX_ENTITIES];
} Game;
@@ -17,3 +18,4 @@ void game_draw(Game *this);
void game_restart_scene(Game *this);
Entity *game_create_entity(Game *this);
int game_entity_count(Game *this, unsigned int type);
+Entity *game_get_entity(Game *this, unsigned int type);