player health

This commit is contained in:
2025-10-06 17:45:58 +01:00
parent fcc7adfb22
commit d54b4df4c2
4 changed files with 7 additions and 1 deletions

View File

@@ -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];

View File

@@ -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");

View File

@@ -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;
}

View File

@@ -29,7 +29,7 @@ struct Player
U32 bulletsLoaded;
ControlState controls;
V2f shotPos;
U32 health;
F32 reloadTimer;
};