#include "m_gameover.h" #include "jgame.h" #include "controller.h" #include "jdraw.h" #include "jaudio.h" #include "actor.h" #include "room.h" #include "config.h" #include namespace modules { namespace gameover { actor::actor_t *heroi = nullptr; char time_text[7] = " 00:00"; void init() { if (audio::getCurrentMusic() != "mus_gameover.ogg") audio::playMusic("mus_gameover.ogg", 0); if (actor::hero::isPrologo()) { heroi = actor::create("HERO", {16, 32, 0}, {6, 6, 8}, "gat.gif", {0, 0, 24, 28}, {-4, 32}); } else { 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 ? ' ' : (minutes/100)+48; time_text[1] = minutes<10 ? ' ' : ((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 (controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK)) { if (heroi) actor::remove(heroi); heroi = nullptr; return false; } draw::cls(2); draw::color(1); draw::swapcol(1, WHITE); actor::update(heroi, false); actor::drawAt(heroi, 150, 176); draw::print2("THE POOL", 16, 3, TEAL, FONT_ZOOM_VERTICAL); draw::print2("GAME OVER", 15, 7, YELLOW, FONT_ZOOM_VERTICAL); if (actor::hero::isPrologo()) { int num_objectes = 0; for (int i=0;i<4;++i) if (actor::hero::getPrologoObjectState(i)==PROLOGO_OBJECT_LEFT) num_objectes++; draw::print2(num_objectes, 2, 8, 12, TEAL, FONT_ZOOM_NONE); draw::print2("OBJECTES DEJATS", 13, 12, GREEN, FONT_ZOOM_NONE); } else { draw::print2(actor::stats::getNumPartsCollected(), 2, 8, 12, TEAL, FONT_ZOOM_NONE); draw::print2("PARTS TROBADES", 13, 12, GREEN, FONT_ZOOM_NONE); } draw::print2(actor::stats::getRoomsVisited(), 2, 8, 14, TEAL, FONT_ZOOM_NONE); draw::print2("HABITACIONS VISITADES", 13, 14, GREEN, FONT_ZOOM_NONE); draw::print2(actor::stats::getLivesLost(), 2, 8, 16, TEAL, FONT_ZOOM_NONE); draw::print2("VIDES PERDUDES", 13, 16, GREEN, FONT_ZOOM_NONE); draw::print2(time_text, 4, 18, TEAL, FONT_ZOOM_NONE); draw::print2("TEMPS TOTAL", 13, 18, GREEN, FONT_ZOOM_NONE); if (actor::hero::getNumAmbernicsCollected()>0) { draw::print2(actor::hero::getNumAmbernicsCollected(), 2, 8, 20, TEAL, FONT_ZOOM_NONE); draw::print2("ANBERNICS ARREPLEGADES", 13, 20, GREEN, FONT_ZOOM_NONE); } draw::print2("(C) JAILDOCTOR 2024", 11, 28, TEAL, FONT_ZOOM_NONE); draw::render(); return true; } } }