diff --git a/code/first.c b/code/first.c index e079e81..a541ca9 100644 --- a/code/first.c +++ b/code/first.c @@ -143,6 +143,7 @@ int main(int argc, char **argv) world->player.collision.size.y = 2; world->player.bulletsLoaded = PLAYER_BULLET_COUNT; world->player.reloadTimer = 0; + world->player.health = 3; world->player.currentArea = WORLD_AREA_OUTSIDE; for(int i =0; i< 4200; i++) { world->map[i] = map[i]; diff --git a/code/game/impl/bandit.c b/code/game/impl/bandit.c index f9a311d..d24f62c 100644 --- a/code/game/impl/bandit.c +++ b/code/game/impl/bandit.c @@ -73,6 +73,7 @@ void UpdateBandit(F32 delta, Bandit *bandit, World *world) { if(AABB_Slab(bandit->collision.pos, banditShot, world->player.collision)){ // gets shot lmao printf("hit"); + world->player.health--; } if(bandit->bullets == 0){ printf("enemy reload"); diff --git a/code/game/impl/player.c b/code/game/impl/player.c index 70f89b8..a58a36a 100644 --- a/code/game/impl/player.c +++ b/code/game/impl/player.c @@ -53,6 +53,10 @@ void PlayerInput(SDL_Event *event, Player *player) void PlayerUpdate(F32 delta, Player *player) { player->controls.shot = false; V2f dir = V2F(0, 0); + if(player->health == 0){ + printf("dead :("); + player->health = 3; + } if(player->controls.upDown) { dir.y -= 1; } diff --git a/code/game/player.h b/code/game/player.h index 627bc1f..c7922d8 100644 --- a/code/game/player.h +++ b/code/game/player.h @@ -29,7 +29,7 @@ struct Player U32 bulletsLoaded; ControlState controls; V2f shotPos; - + U32 health; F32 reloadTimer; };