player health

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

No files matched your search

+1
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];
+1
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");
+4
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;
}
+1 -1
View File
@@ -29,7 +29,7 @@ struct Player
U32 bulletsLoaded;
ControlState controls;
V2f shotPos;
U32 health;
F32 reloadTimer;
};