forked from jaildesigner-jailgames/jaildoctors_dilemma
Afegint smart pointers
Actualitzat Resources Actualitzades les classes Sprite i derivades Afegida nova tipografia Actualitzat Asset Actualitzat Text
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
#include "game_over.h"
|
||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||
#include <algorithm> // Para min, max
|
||||
#include <string> // Para basic_string, operator+, to_string, char...
|
||||
#include "animatedsprite.h" // Para AnimatedSprite
|
||||
#include "asset.h" // Para Asset
|
||||
#include "const.h" // Para GAMECANVAS_CENTER_X, SECTION_GAME_OVER
|
||||
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e
|
||||
#include "jail_audio.h" // Para JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic
|
||||
#include "resource.h" // Para Resource
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, TXT_CENTER, TXT_COLOR
|
||||
#include "texture.h" // Para Texture
|
||||
#include <SDL2/SDL_timer.h> // Para SDL_GetTicks
|
||||
#include <algorithm> // Para min, max
|
||||
#include <string> // Para basic_string, operator+, to_string, char...
|
||||
#include "animated_sprite.h" // Para AnimatedSprite
|
||||
#include "asset.h" // Para Asset
|
||||
#include "const.h" // Para GAMECANVAS_CENTER_X, SECTION_GAME_OVER
|
||||
#include "input.h" // Para Input, REPEAT_FALSE, inputs_e
|
||||
#include "jail_audio.h" // Para JA_DeleteMusic, JA_LoadMusic, JA_PlayMusic
|
||||
#include "resource.h" // Para Resource
|
||||
#include "screen.h" // Para Screen
|
||||
#include "text.h" // Para Text, TEXT_CENTER, TEXT_COLOR
|
||||
#include "texture.h" // Para Texture
|
||||
#include "options.h"
|
||||
#include "global_inputs.h"
|
||||
#include "global_events.h"
|
||||
@@ -24,10 +24,10 @@ GameOver::GameOver()
|
||||
input(Input::get())
|
||||
{
|
||||
// Reserva memoria para los punteros a objetos
|
||||
text = new Text(resource->getOffset("smb2.txt"), resource->getTexture("smb2.png"), renderer);
|
||||
playerSprite = new AnimatedSprite(renderer, resource->getAnimation("player_game_over.ani"));
|
||||
tvSprite = new AnimatedSprite(renderer, resource->getAnimation("tv.ani"));
|
||||
music = JA_LoadMusic(asset->get("game_over.ogg").c_str());
|
||||
text = resource->getText("smb2.txt");
|
||||
playerSprite = std::make_shared<AnimatedSprite>(resource->getTexture("player_game_over.png"), resource->getAnimation("player_game_over.ani"));
|
||||
tvSprite = std::make_shared<AnimatedSprite>(resource->getTexture("tv.png"), resource->getAnimation("tv.ani"));
|
||||
music = resource->getMusic("game_over.ogg");
|
||||
|
||||
// Inicializa variables
|
||||
preCounter = 0;
|
||||
@@ -41,7 +41,7 @@ GameOver::GameOver()
|
||||
fadeLenght = 20;
|
||||
playerSprite->setPosX(GAMECANVAS_CENTER_X + 10);
|
||||
playerSprite->setPosY(30);
|
||||
tvSprite->setPosX(GAMECANVAS_CENTER_X - tvSprite->getAnimationClip(0, 0).w - 10);
|
||||
tvSprite->setPosX(GAMECANVAS_CENTER_X - tvSprite->getWidth() - 10);
|
||||
tvSprite->setPosY(30);
|
||||
|
||||
// Inicializa el vector de colores
|
||||
@@ -53,16 +53,6 @@ GameOver::GameOver()
|
||||
color = colors.back();
|
||||
}
|
||||
|
||||
// Destructor
|
||||
GameOver::~GameOver()
|
||||
{
|
||||
// Libera la memoria de los objetos
|
||||
delete text;
|
||||
delete playerSprite;
|
||||
delete tvSprite;
|
||||
JA_DeleteMusic(music);
|
||||
}
|
||||
|
||||
// Actualiza el objeto
|
||||
void GameOver::update()
|
||||
{
|
||||
@@ -101,7 +91,7 @@ void GameOver::render()
|
||||
screen->clean();
|
||||
|
||||
// Escribe el texto de GAME OVER
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y, "G A M E O V E R", 1, color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, y, "G A M E O V E R", 1, color);
|
||||
|
||||
// Dibuja los sprites
|
||||
playerSprite->setPosY(y + 30);
|
||||
@@ -111,12 +101,12 @@ void GameOver::render()
|
||||
// Escribe el texto con las habitaciones y los items
|
||||
const std::string itemsTxt = std::to_string(options.stats.items / 100) + std::to_string((options.stats.items % 100) / 10) + std::to_string(options.stats.items % 10);
|
||||
const std::string roomsTxt = std::to_string(options.stats.rooms / 100) + std::to_string((options.stats.rooms % 100) / 10) + std::to_string(options.stats.rooms % 10);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 80, "ITEMS: " + itemsTxt, 1, color);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 90, "ROOMS: " + roomsTxt, 1, color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, y + 80, "ITEMS: " + itemsTxt, 1, color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, y + 90, "ROOMS: " + roomsTxt, 1, color);
|
||||
|
||||
// Escribe el texto con "Tu peor pesadilla"
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 110, "YOUR WORST NIGHTMARE IS", 1, color);
|
||||
text->writeDX(TXT_CENTER | TXT_COLOR, GAMECANVAS_CENTER_X, y + 120, options.stats.worst_nightmare, 1, color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, y + 110, "YOUR WORST NIGHTMARE IS", 1, color);
|
||||
text->writeDX(TEXT_CENTER | TEXT_COLOR, GAMECANVAS_CENTER_X, y + 120, options.stats.worst_nightmare, 1, color);
|
||||
|
||||
// Vuelca el contenido del renderizador en pantalla
|
||||
screen->render();
|
||||
|
||||
Reference in New Issue
Block a user