- [NEW] Els stats del final també mostren el temps empleat

- [NEW] La música i el audio sonen o no segons la configuració
This commit is contained in:
2024-10-02 12:32:43 +02:00
parent 0ca9ad3f0b
commit 5620fff446
5 changed files with 37 additions and 12 deletions

View File

@@ -860,7 +860,7 @@ namespace actor
{ {
act->flags |= FLAG_ANIMATED; act->flags |= FLAG_ANIMATED;
//if (audio::getChannelState(walk_channel) == audio::CHANNEL_PAUSED) audio::resumeChannel(walk_channel); //if (audio::getChannelState(walk_channel) == audio::CHANNEL_PAUSED) audio::resumeChannel(walk_channel);
if (act->anim_frame==0) walk_channel = audio::playSound(walk, 0); if ( (config::getSoundMode()==SOUND_ALL) && (act->anim_frame==0)) walk_channel = audio::playSound(walk, 0);
} }
else else
{ {
@@ -1890,7 +1890,7 @@ namespace actor
boosters_collected[i] = false; boosters_collected[i] = false;
brilli = draw::getSurface("objectes.gif"); brilli = draw::getSurface("objectes.gif");
walk = audio::loadSound("walk.wav"); if (config::getSoundMode()==SOUND_ALL) walk = audio::loadSound("walk.wav");
//walk_channel = audio::playSound(walk, -1); //walk_channel = audio::playSound(walk, -1);
//audio::pauseChannel(walk_channel); //audio::pauseChannel(walk_channel);
} }
@@ -2176,6 +2176,7 @@ namespace actor
bool roomVisited[MAX_ROOMS]; bool roomVisited[MAX_ROOMS];
int livesLost = 0; int livesLost = 0;
int catsLifeOdds = 5; int catsLifeOdds = 5;
uint32_t start_time = 0;
void reset() void reset()
{ {
@@ -2183,6 +2184,7 @@ namespace actor
catsLifeOdds = 5; catsLifeOdds = 5;
for (int i = 0; i < MAX_ROOMS; ++i) for (int i = 0; i < MAX_ROOMS; ++i)
roomVisited[i] = false; roomVisited[i] = false;
start_time = SDL_GetTicks();
} }
void collectPart() { partsCollected++; } void collectPart() { partsCollected++; }
@@ -2199,6 +2201,8 @@ namespace actor
return roomsVisited; return roomsVisited;
} }
uint32_t getStartTime() { return start_time; }
int getLivesLost() { return livesLost; } int getLivesLost() { return livesLost; }
bool catsLife() bool catsLife()

View File

@@ -245,6 +245,7 @@ namespace actor
int getNumPartsCollected(); int getNumPartsCollected();
int getRoomsVisited(); int getRoomsVisited();
uint32_t getStartTime();
int getLivesLost(); int getLivesLost();
bool catsLife(); bool catsLife();

View File

@@ -8,7 +8,7 @@
#include "editor.h" #include "editor.h"
#include "jutil.h" #include "jutil.h"
#include "jaudio.h" #include "jaudio.h"
#include "config.h"
namespace modules namespace modules
{ {
namespace game namespace game
@@ -42,8 +42,11 @@ namespace modules
} }
fclose(f); fclose(f);
} else { } else {
auto musica = audio::loadMusic("ingame.ogg"); if (config::isMusicEnabled())
audio::playMusic(musica); {
auto musica = audio::loadMusic("ingame.ogg");
audio::playMusic(musica);
}
} }
actor::hero::init(); actor::hero::init();

View File

@@ -12,18 +12,30 @@ namespace modules
namespace gameover namespace gameover
{ {
actor::actor_t *heroi = nullptr; actor::actor_t *heroi = nullptr;
char time_text[7] = "000:00";
void init() void init()
{ {
if (heroi == nullptr) heroi = actor::create("HERO", {16,32,8}, {6,6,12}, "test.gif", {0,32,20,32}, {-6,38}); if (heroi == nullptr) heroi = actor::create("HERO", {16,32,8}, {6,6,12}, "test.gif", {0,32,20,32}, {-6,38});
heroi->flags = FLAG_ANIMATED; heroi->flags = FLAG_ANIMATED;
int milliseconds = SDL_GetTicks()-actor::stats::getStartTime();
int seconds = milliseconds/1000;
int minutes = seconds / 60;
seconds = seconds % 60;
time_text[0] = (minutes/100)+48;
time_text[1] = ((minutes%100)/10)+48;
time_text[2] = (minutes%10)+48;
time_text[4] = (seconds/10)+48;
time_text[5] = (seconds%10)+48;
time_text[6] = 0;
} }
bool loop() bool loop()
{ {
if (input::keyPressed(SDL_SCANCODE_SPACE)) { if (input::keyPressed(SDL_SCANCODE_SPACE)) { return false; }
return false;
}
draw::cls(2); draw::cls(2);
draw::color(1); draw::color(1);
@@ -35,15 +47,17 @@ namespace modules
draw::print2("GAME OVER", 15, 7, YELLOW, FONT_ZOOM_VERTICAL); draw::print2("GAME OVER", 15, 7, YELLOW, FONT_ZOOM_VERTICAL);
draw::print2(actor::stats::getNumPartsCollected(), 2, 11, 12, GREEN, FONT_ZOOM_NONE); draw::print2(actor::stats::getNumPartsCollected(), 2, 11, 12, TEAL, FONT_ZOOM_NONE);
draw::print2("PARTS TROBADES", 14, 12, GREEN, FONT_ZOOM_NONE); draw::print2("PARTS TROBADES", 14, 12, GREEN, FONT_ZOOM_NONE);
draw::print2(actor::stats::getRoomsVisited(), 2, 8, 14, GREEN, FONT_ZOOM_NONE); draw::print2(actor::stats::getRoomsVisited(), 2, 8, 14, TEAL, FONT_ZOOM_NONE);
draw::print2("HABITACIONS VISITADES", 11, 14, GREEN, FONT_ZOOM_NONE); draw::print2("HABITACIONS VISITADES", 11, 14, GREEN, FONT_ZOOM_NONE);
draw::print2(actor::stats::getLivesLost(), 2, 11, 16, GREEN, FONT_ZOOM_NONE); draw::print2(actor::stats::getLivesLost(), 2, 11, 16, TEAL, FONT_ZOOM_NONE);
draw::print2("VIDES PERDUDES", 14, 16, GREEN, FONT_ZOOM_NONE); draw::print2("VIDES PERDUDES", 14, 16, GREEN, FONT_ZOOM_NONE);
draw::print2(time_text, 11, 18, TEAL, FONT_ZOOM_NONE);
draw::print2("TEMPS TOTAL", 18, 18, GREEN, FONT_ZOOM_NONE);
draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE); draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE);

View File

@@ -17,7 +17,10 @@ namespace modules
void init() void init()
{ {
audio::stopMusic(); if (config::isMusicEnabled())
{
audio::stopMusic();
}
selected_option = OPTION_JUGAR; selected_option = OPTION_JUGAR;
::game::setUpdateTicks(64); ::game::setUpdateTicks(64);
draw::loadPalette("test.gif"); draw::loadPalette("test.gif");