summaryrefslogtreecommitdiff
path: root/src/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.c')
-rw-r--r--src/game.c14
1 files changed, 13 insertions, 1 deletions
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;
+}