- [NEW] Pantalla de game over

- [NEW] Stats
This commit is contained in:
2024-07-24 23:05:24 +02:00
parent 3a51938d80
commit 0a1b4f8715
8 changed files with 165 additions and 15 deletions

View File

@@ -720,6 +720,7 @@ namespace actor
if ( (act->push & PUSH_KILL) && (act->flags & FLAG_HERO) ) {
const int lives = hero::getLives()-1;
hero::setLives(lives);
stats::loseLive();
// [TODO] If lives == 0 anar a la pantalla de game-over o cat's life
actor_t *act = actor::find("HERO");
act = actor::replaceWithTemplate(act, "EXPLOSION");
@@ -1342,6 +1343,7 @@ namespace actor
bool boosters_collected[100];
vec3_t first_pos = {0,0,0};
int first_orient = 0;
bool dead = false;
void init(const bool complete)
{
@@ -1350,9 +1352,11 @@ namespace actor
actor::setDirty(hero, true);
boost_jumps = boost_steps = boost_god = 0;
dead = false;
if (complete)
{
stats::reset();
lives = 8;
skills = SKILL_NONE;
parts = PART_NONE;
@@ -1374,6 +1378,16 @@ namespace actor
lives = value;
}
void die()
{
dead = true;
}
bool isDead()
{
return dead;
}
const int getBoosterFromString(char *booster)
{
static const char *boostset_name[4] = {"RUN", "GOD", "JUMP", "LIVE"};
@@ -1510,6 +1524,7 @@ namespace actor
{
const int value = getPartFromString(part);
parts |= value;
if (value!=0) stats::collectPart();
return value!=0;
}
@@ -1546,4 +1561,32 @@ namespace actor
}
}
namespace stats
{
int partsCollected = 0;
bool roomVisited[MAX_ROOMS];
int livesLost = 0;
void reset()
{
partsCollected = livesLost = 0;
for (int i=0; i<MAX_ROOMS; ++i) roomVisited[i] = false;
}
void collectPart() { partsCollected++; }
void visitRoom(int room) {roomVisited[room] = true; }
void loseLive() { livesLost++; }
int getNumPartsCollected() { return partsCollected; }
int getRoomsVisited()
{
int roomsVisited = 0;
for (int i=0; i<MAX_ROOMS; ++i) if (roomVisited[i]) roomsVisited++;
return roomsVisited;
}
int getLivesLost() { return livesLost; }
}
}