Files
thepool/source/m_gameover.cpp
Raimon Zamora e009aef341 - [CHG] Retocat el mòdul JAudio per a adaptar-se a les necesitats del joc.
- [NEW] audio::getCurrentMusic()
- [NEW] audio::stopAllChannels()
- [FIX] El JAudio i JInput han de inicialitzarse abans de entrar al Init del joc
- Afegides músiques i alguns sons
- Comence a fer que sone cada musica i so en el seu lloc
- [TOFIX] LAG EN EL AUDIO!
2024-10-03 13:09:44 +02:00

72 lines
2.2 KiB
C++

#include "m_gameover.h"
#include "jgame.h"
#include "jinput.h"
#include "jdraw.h"
#include "jaudio.h"
#include "actor.h"
#include "room.h"
#include "config.h"
#include <SDL2/SDL.h>
namespace modules
{
namespace gameover
{
actor::actor_t *heroi = nullptr;
char time_text[7] = "000:00";
void init()
{
audio::playMusic("mus_gameover.ogg");
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;
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()
{
if (input::keyPressed(SDL_SCANCODE_SPACE)) { return false; }
draw::cls(2);
draw::color(1);
draw::swapcol(1, WHITE);
actor::update(heroi, false);
actor::drawAt(heroi, 150, 160);
draw::print2("THE POOL", 16, 3, TEAL, FONT_ZOOM_VERTICAL);
draw::print2("GAME OVER", 15, 7, YELLOW, FONT_ZOOM_VERTICAL);
draw::print2(actor::stats::getNumPartsCollected(), 2, 11, 12, TEAL, FONT_ZOOM_NONE);
draw::print2("PARTS TROBADES", 14, 12, 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(actor::stats::getLivesLost(), 2, 11, 16, TEAL, 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::render();
return true;
}
}
}