summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkdx <kikoodx@paranoici.org>2023-03-18 19:15:05 +0100
committerkdx <kikoodx@paranoici.org>2023-03-18 19:15:05 +0100
commit11b10c227cfccec717b8b7206f33a8bce24a54dc (patch)
tree750c1f9daf319934f2ca1729b63e0fecc08bbf1d
parentef3cf8e9df99856d4c322afd17fed5e3e15f383b (diff)
downloadhyperultra-11b10c227cfccec717b8b7206f33a8bce24a54dc.tar.gz
u dedge
-rw-r--r--src/entity.c3
-rw-r--r--src/entity.h2
-rw-r--r--src/game.c4
-rw-r--r--src/game.h1
-rw-r--r--src/player.c3
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;
diff --git a/src/game.c b/src/game.c
index a3c7cd9..6ca8db0 100644
--- a/src/game.c
+++ b/src/game.c
@@ -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();
diff --git a/src/game.h b/src/game.h
index 10ebe84..edbd689 100644
--- a/src/game.h
+++ b/src/game.h
@@ -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;
}