From 381886fe9666c19ca3e79ea283eb150a80147f4d Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Sun, 14 Apr 2024 14:34:01 +0800 Subject: [PATCH] Add a cutoff height to player system --- player.c | 3 ++- player.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/player.c b/player.c index 3646a56..5fe067f 100644 --- a/player.c +++ b/player.c @@ -21,6 +21,7 @@ System_Player *player_NewSystem(App *super) { System_Player *sys = malloc(sizeof(System_Player)); sys->super = super; sys->player = NULL; + sys->cutoff = 5000.0; return sys; } void player_DeleteSystem(System_Player *sys) { @@ -152,7 +153,7 @@ void player_Advance(System_Player *sys, Duration deltaTime) { // Respawn if fallen out of the world - if (p->super->position->position.y > 5000) + if (p->super->position->position.y > sys->cutoff) player_HazardHarm(sys); diff --git a/player.h b/player.h index 6ad65eb..4c693e9 100644 --- a/player.h +++ b/player.h @@ -39,6 +39,10 @@ typedef struct { // The player in the world. // Control is paused if equals NULL. Component_Player *player; + + // Cutoff Y position. + // If the player is lower than this position, the player is environment harmed. + double cutoff; } System_Player; System_Player *player_NewSystem(App *super);