añadido map.h y map.cpp

This commit is contained in:
2022-07-01 20:21:28 +02:00
parent 37325a2ec3
commit 661b920dfa
7 changed files with 70 additions and 32 deletions

View File

@@ -10,6 +10,7 @@ Game::Game(SDL_Window *window,SDL_Renderer *renderer, Asset *asset, Lang *lang,
mInput = input;
mScreen = new Screen(window, renderer);
mMap = new Map();
mEventHandler = new SDL_Event();
mTextureText = new LTexture();
mText = new Text(mAsset->get("nokia2.txt"), mTextureText, renderer);
@@ -33,6 +34,9 @@ Game::~Game()
delete mScreen;
mScreen = nullptr;
delete mMap;
mMap = nullptr;
delete mText;
mText = nullptr;
@@ -49,8 +53,8 @@ void Game::init()
mTicks = 0;
mTicksSpeed = 15;
mSection.name = PROG_SECTION_GAME;
mSection.subsection = GAME_SECTION_PLAY_1P;
mSection.name = SECTION_PROG_GAME;
mSection.subsection = SECTION_GAME_PLAY;
}
// Carga los recursos necesarios para la sección 'Game'
@@ -69,10 +73,10 @@ section_t Game::run()
{
init();
while (mSection.name == PROG_SECTION_GAME)
while (mSection.name == SECTION_PROG_GAME)
{
// Sección juego jugando
if ((mSection.subsection == GAME_SECTION_PLAY_1P) || (mSection.subsection == GAME_SECTION_PLAY_2P))
if (mSection.subsection == SECTION_GAME_PLAY)
{
// Comprueba que la diferencia de ticks sea mayor a la velocidad del juego
if (SDL_GetTicks() - mTicks > mTicksSpeed)
@@ -86,7 +90,7 @@ section_t Game::run()
// Evento de salida de la aplicación
if (mEventHandler->type == SDL_QUIT)
{
mSection.name = PROG_SECTION_QUIT;
mSection.name = SECTION_PROG_QUIT;
break;
}
}
@@ -102,7 +106,7 @@ section_t Game::run()
mText->write(0, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), std::to_string(GAMECANVAS_HEIGHT), -1);
// Texto en el centro de la pantalla
mText->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), "Pepe el Cazavampiros", -1);
mText->writeCentered(GAMECANVAS_CENTER_X, GAMECANVAS_CENTER_Y - (mText->getCharacterWidth() / 2), "New JailGame", -1);
// Actualiza la pantalla
mScreen->blit();