diff options
author | kdx <kikoodx@paranoici.org> | 2023-03-18 19:15:05 +0100 |
---|---|---|
committer | kdx <kikoodx@paranoici.org> | 2023-03-18 19:15:05 +0100 |
commit | 11b10c227cfccec717b8b7206f33a8bce24a54dc (patch) | |
tree | 750c1f9daf319934f2ca1729b63e0fecc08bbf1d | |
parent | ef3cf8e9df99856d4c322afd17fed5e3e15f383b (diff) | |
download | hyperultra-11b10c227cfccec717b8b7206f33a8bce24a54dc.tar.gz |
u dedge
-rw-r--r-- | src/entity.c | 3 | ||||
-rw-r--r-- | src/entity.h | 2 | ||||
-rw-r--r-- | src/game.c | 4 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/player.c | 3 |
5 files changed, 12 insertions, 1 deletions
diff --git a/src/entity.c b/src/entity.c index 001b9e1..9b378aa 100644 --- a/src/entity.c +++ b/src/entity.c @@ -47,6 +47,7 @@ entity_place_meeting(Entity *this, Game *g, EntityType type) void entity_move(Entity *this, Game *g) { + this->bonk_ceiling = false; if (entity_collide(this, g, 0, 0)) { this->vel[0] = 0.0; this->vel[1] = 0.0; @@ -67,6 +68,8 @@ entity_move(Entity *this, Game *g) this->pos[a] -= sign; this->rem[a] = 0.0; this->vel[a] = 0.0; + if (a == 1 && sign == -1) + this->bonk_ceiling = true; break; } spd -= sign; diff --git a/src/entity.h b/src/entity.h index 9460273..f8ab5ad 100644 --- a/src/entity.h +++ b/src/entity.h @@ -23,7 +23,7 @@ struct Entity { double rem[2]; int width; int height; - bool solid; + bool bonk_ceiling; union { Player player; Exit exit; @@ -21,6 +21,10 @@ game_deinit(Game *this) void game_update(Game *this) { + if (this->queue_restart_scene) { + this->queue_restart_scene = false; + game_restart_scene(this); + } if (this->queue_next_scene) { this->queue_next_scene = false; map_next(); @@ -6,6 +6,7 @@ enum { MAX_ENTITIES = 64 }; typedef struct Game { unsigned int uuid; bool queue_next_scene; + bool queue_restart_scene; Entity entities[MAX_ENTITIES]; } Game; diff --git a/src/player.c b/src/player.c index c729085..70ccb20 100644 --- a/src/player.c +++ b/src/player.c @@ -49,6 +49,9 @@ player_update(Entity *this, Game *g) if (this->vel[0] == 0.0 && this->vel[1] >= -0.0) this->player.dirx *= -1; + if (this->bonk_ceiling) + g->queue_restart_scene = true; + if (entity_place_meeting(this, g, ET_EXIT) != NULL) g->queue_next_scene = true; } |