life interaction? i guess

This commit is contained in:
Djalim Simaila 2022-01-09 00:22:03 +01:00
parent 6faffb7baf
commit 4737d9dcb3
3 changed files with 3 additions and 3 deletions

View File

@ -2,7 +2,7 @@
#define GUARD_PLAYER_H
struct Player{
unsigned lives;
unsigned lives = 3;
unsigned x;
unsigned id;
unsigned score=0;

View File

@ -35,9 +35,8 @@ void Game::displayAll(unsigned fps) const {
// As said before, the player loop is an illusion, 2 players max
for(unsigned i=0;i<players[0].lives;++i){
pm.drawHeart(Position(i * 70, 70));
}
pm.drawHeart(Position(0, 70));
}
void Game::displayHearts(playerID pID) const {

View File

@ -141,6 +141,7 @@ bool Game::checkMissilesAndPlayers() {
miss_ite->getX(), miss_ite->getX() + confData.missilesWidth,
p.x, p.x + confData.playersWidth)){
wasColliding = true;
--p.lives;
if(p.deathAnimCounter)p.deathAnimCounter = 1;
// do not break, the second player also deserves to be hit
}