diff --git a/source/common/screen.cpp b/source/common/screen.cpp index fcfc9f4..bfe7a96 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -383,9 +383,9 @@ void Screen::renderNotifications() return; } - //SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight); + SDL_RenderSetLogicalSize(renderer, notificationLogicalWidth, notificationLogicalHeight); notify->render(); - //SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); + SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); } // Establece el tamaño de las notificaciones diff --git a/source/common/text.cpp b/source/common/text.cpp index 8b93493..4563b2a 100644 --- a/source/common/text.cpp +++ b/source/common/text.cpp @@ -95,6 +95,9 @@ Text::Text(std::string bitmapFile, std::string textFile, SDL_Renderer *renderer) // Crea los objetos texture = new Texture(renderer, bitmapFile); sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer); + + // Inicializa variables + fixedWidth = false; } // Constructor @@ -114,6 +117,7 @@ Text::Text(std::string textFile, Texture *texture, SDL_Renderer *renderer) } // Crea los objetos + this->texture = nullptr; sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer); // Inicializa variables @@ -134,6 +138,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) } // Crea los objetos + this->texture = nullptr; sprite = new Sprite({0, 0, boxWidth, boxHeight}, texture, renderer); // Inicializa variables @@ -144,7 +149,7 @@ Text::Text(textFile_t *textFile, Texture *texture, SDL_Renderer *renderer) Text::~Text() { delete sprite; - if (texture) + if (texture != nullptr) { delete texture; } @@ -156,15 +161,19 @@ void Text::write(int x, int y, std::string text, int kerning, int lenght) int shift = 0; if (lenght == -1) + { lenght = text.length(); + } + sprite->setPosY(y); + const int width = sprite->getWidth(); + const int height = sprite->getHeight(); for (int i = 0; i < lenght; ++i) { - sprite->setSpriteClip(offset[int(text[i])].x, offset[int(text[i])].y, sprite->getWidth(), sprite->getHeight()); + const int index = text[i]; + sprite->setSpriteClip(offset[index].x, offset[index].y, width, height); sprite->setPosX(x + shift); - sprite->setPosY(y); sprite->render(); - // shift += (offset[int(text[i])].w + kerning); shift += fixedWidth ? boxWidth : (offset[int(text[i])].w + kerning); } } diff --git a/source/common/texture.cpp b/source/common/texture.cpp index 980d853..fa190d5 100644 --- a/source/common/texture.cpp +++ b/source/common/texture.cpp @@ -92,7 +92,8 @@ bool Texture::loadFromFile(std::string path, SDL_Renderer *renderer) SDL_FreeSurface(loadedSurface); } - // Return success + // Devuelve el resultado + stbi_image_free(data); texture = newTexture; return texture != nullptr; } diff --git a/source/const.h b/source/const.h index 0b69fdf..2ec01e8 100644 --- a/source/const.h +++ b/source/const.h @@ -11,15 +11,15 @@ #define BLOCK 8 #define HALF_BLOCK BLOCK / 2 -// Tamaño de la pantalla de juego -#define GAME_WIDTH 256 -#define GAME_HEIGHT 192 +// Tamaño de la pantalla virtual +#define GAMECANVAS_WIDTH 256 +#define GAMECANVAS_HEIGHT 192 // Zona de juego const int PLAY_AREA_TOP = (0 * BLOCK); -const int PLAY_AREA_BOTTOM = GAME_HEIGHT - (4 * BLOCK); +const int PLAY_AREA_BOTTOM = GAMECANVAS_HEIGHT - (4 * BLOCK); const int PLAY_AREA_LEFT = (0 * BLOCK); -const int PLAY_AREA_RIGHT = GAME_WIDTH - (0 * BLOCK); +const int PLAY_AREA_RIGHT = GAMECANVAS_WIDTH - (0 * BLOCK); const int PLAY_AREA_WIDTH = PLAY_AREA_RIGHT - PLAY_AREA_LEFT; const int PLAY_AREA_HEIGHT = PLAY_AREA_BOTTOM - PLAY_AREA_TOP; const int PLAY_AREA_CENTER_X = PLAY_AREA_LEFT + (PLAY_AREA_WIDTH / 2); @@ -30,12 +30,12 @@ const int PLAY_AREA_FIRST_QUARTER_Y = PLAY_AREA_HEIGHT / 4; const int PLAY_AREA_THIRD_QUARTER_Y = (PLAY_AREA_HEIGHT / 4) * 3; // Anclajes de pantalla -const int SCREEN_CENTER_X = GAME_WIDTH / 2; -const int SCREEN_FIRST_QUARTER_X = GAME_WIDTH / 4; -const int SCREEN_THIRD_QUARTER_X = (GAME_WIDTH / 4) * 3; -const int SCREEN_CENTER_Y = GAME_HEIGHT / 2; -const int SCREEN_FIRST_QUARTER_Y = GAME_HEIGHT / 4; -const int SCREEN_THIRD_QUARTER_Y = (GAME_HEIGHT / 4) * 3; +const int GAMECANVAS_CENTER_X = GAMECANVAS_WIDTH / 2; +const int GAMECANVAS_FIRST_QUARTER_X = GAMECANVAS_WIDTH / 4; +const int GAMECANVAS_THIRD_QUARTER_X = (GAMECANVAS_WIDTH / 4) * 3; +const int GAMECANVAS_CENTER_Y = GAMECANVAS_HEIGHT / 2; +const int GAMECANVAS_FIRST_QUARTER_Y = GAMECANVAS_HEIGHT / 4; +const int GAMECANVAS_THIRD_QUARTER_Y = (GAMECANVAS_HEIGHT / 4) * 3; // Secciones del programa #define PROG_SECTION_LOGO 0 diff --git a/source/director.cpp b/source/director.cpp index c426053..908d965 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -321,6 +321,8 @@ void Director::initOptions() inp.deviceType = INPUT_USE_GAMECONTROLLER; options->input.push_back(inp); + options->gameWidth = GAMECANVAS_WIDTH; + options->gameHeight = GAMECANVAS_HEIGHT; options->videoMode = 0; options->windowSize = 3; options->language = ba_BA; diff --git a/source/fade.cpp b/source/fade.cpp index f8caef2..48823bc 100644 --- a/source/fade.cpp +++ b/source/fade.cpp @@ -6,7 +6,7 @@ Fade::Fade(SDL_Renderer *renderer) { mRenderer = renderer; - mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT); + mBackbuffer = SDL_CreateTexture(mRenderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); if (mBackbuffer == nullptr) printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError()); } @@ -38,7 +38,7 @@ void Fade::render() switch (mFadeType) { case FADE_FULLSCREEN: - mRect1 = {0, 0, GAME_WIDTH, GAME_HEIGHT}; + mRect1 = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; for (int i = 0; i < 256; i += 4) { @@ -66,21 +66,21 @@ void Fade::render() break; case FADE_CENTER: - mRect1 = {0, 0, GAME_WIDTH, 0}; - mRect2 = {0, 0, GAME_WIDTH, 0}; + mRect1 = {0, 0, GAMECANVAS_WIDTH, 0}; + mRect2 = {0, 0, GAMECANVAS_WIDTH, 0}; SDL_SetRenderDrawColor(mRenderer, mR, mG, mB, 64); for (int i = 0; i < mCounter; i++) { mRect1.h = mRect2.h = i * 4; - mRect2.y = GAME_HEIGHT - (i * 4); + mRect2.y = GAMECANVAS_HEIGHT - (i * 4); SDL_RenderFillRect(mRenderer, &mRect1); SDL_RenderFillRect(mRenderer, &mRect2); } - if ((mCounter * 4) > GAME_HEIGHT) + if ((mCounter * 4) > GAMECANVAS_HEIGHT) mFinished = true; break; @@ -98,8 +98,8 @@ void Fade::render() // Dibujamos sobre el backbuffer SDL_SetRenderTarget(mRenderer, mBackbuffer); - mRect1.x = rand() % (GAME_WIDTH - mRect1.w); - mRect1.y = rand() % (GAME_HEIGHT - mRect1.h); + mRect1.x = rand() % (GAMECANVAS_WIDTH - mRect1.w); + mRect1.y = rand() % (GAMECANVAS_HEIGHT - mRect1.h); SDL_RenderFillRect(mRenderer, &mRect1); // Volvemos a usar el renderizador de forma normal diff --git a/source/game.cpp b/source/game.cpp index 3c3e3cc..417d054 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -42,7 +42,7 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr buildingsSprite = new Sprite(0, 0, 256, 160, gameBuildingsTexture, renderer); - skyColorsSprite = new Sprite(0, 0, GAME_WIDTH, GAME_HEIGHT, gameSkyColorsTexture, renderer); + skyColorsSprite = new Sprite(0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT, gameSkyColorsTexture, renderer); grassSprite = new Sprite(0, 0, 256, 6, gameGrassTexture, renderer); powerMeterSprite = new Sprite(PLAY_AREA_CENTER_X - 20, 170, 40, 7, gamePowerMeterTexture, renderer); gameOverSprite = new Sprite(16, 80, 128, 96, gameOverTexture, renderer); @@ -376,10 +376,10 @@ void Game::init() n5000Sprite->setDestY(0); // Los fondos - skyColorsRect[0] = {0, 0, GAME_WIDTH, GAME_HEIGHT}; - skyColorsRect[1] = {256, 0, GAME_WIDTH, GAME_HEIGHT}; - skyColorsRect[2] = {0, 192, GAME_WIDTH, GAME_HEIGHT}; - skyColorsRect[3] = {256, 192, GAME_WIDTH, GAME_HEIGHT}; + skyColorsRect[0] = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; + skyColorsRect[1] = {256, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; + skyColorsRect[2] = {0, 192, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; + skyColorsRect[3] = {256, 192, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; } // Carga los recursos necesarios para la sección 'Game' @@ -1831,7 +1831,7 @@ void Game::renderDeathFade(int counter) { rect[i].x = 0; rect[i].y = i * 16; - rect[i].w = GAME_WIDTH; + rect[i].w = GAMECANVAS_WIDTH; if (i == 0) { rect[i].h = h; @@ -1845,7 +1845,7 @@ void Game::renderDeathFade(int counter) } else { - SDL_Rect rect = {0, 0, GAME_WIDTH, GAME_HEIGHT}; + SDL_Rect rect = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; SDL_RenderFillRect(renderer, &rect); } } @@ -2600,7 +2600,7 @@ void Game::throwCoffee(int x, int y) ss->setAccelX(0.0f); ss->setAccelY(0.2f); ss->setDestX(x + (ss->getVelX() * 50)); - ss->setDestY(GAME_HEIGHT + 1); + ss->setDestY(GAMECANVAS_HEIGHT + 1); ss->setEnabled(true); ss->setEnabledCounter(1); ss->setSpriteClip(0, 0, 16, 16); @@ -3423,7 +3423,7 @@ void Game::renderPausedGame() if (leavingPauseMenu) { - textNokiaBig2->writeCentered(SCREEN_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1)); + textNokiaBig2->writeCentered(GAMECANVAS_CENTER_X, PLAY_AREA_FIRST_QUARTER_Y, std::to_string((pauseCounter / 30) + 1)); } else { diff --git a/source/hiscore_table.cpp b/source/hiscore_table.cpp index ce43eab..af8ae86 100644 --- a/source/hiscore_table.cpp +++ b/source/hiscore_table.cpp @@ -18,7 +18,7 @@ HiScoreTable::HiScoreTable(SDL_Renderer *renderer, Screen *screen, Asset *asset, text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); // Crea un backbuffer para el renderizador - backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT); + backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); if (backbuffer == nullptr) { printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError()); @@ -81,7 +81,7 @@ void HiScoreTable::update() void HiScoreTable::render() { // Pinta en pantalla - SDL_Rect window = {0, 0, GAME_WIDTH, GAME_HEIGHT}; + SDL_Rect window = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; const color_t orangeColor = {0xFF, 0x7A, 0x00}; // hay 27 letras - 7 de puntos quedan 20 caracteres 20 - nameLenght 0 numDots @@ -94,7 +94,7 @@ void HiScoreTable::render() SDL_RenderClear(renderer); // Escribe el texto: Mejores puntuaciones - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, lang->getText(42), 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, lang->getText(42), 1, orangeColor, 1, shdwTxtColor); // Escribe la lista de jugadores int numUsers = jscore::getNumUsers(); @@ -108,7 +108,7 @@ void HiScoreTable::render() dots = dots + "."; } const std::string line = jscore::getUserName(i) + dots + scoreToString(jscore::getPoints(i)); - text->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor); } // Rellena la lista con otros nombres @@ -127,13 +127,13 @@ void HiScoreTable::render() dots = dots + "."; } const std::string line = names.at(i - numUsers) + dots + "0000000"; - text->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, (i * spaceBetweenLines) + spaceBetweenHeader, line, 1, orangeColor, 1, shdwTxtColor); } } if ((mode == mhst_manual) && (counter % 50 > 14)) { - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor); } // Cambia el destino de renderizado @@ -148,7 +148,7 @@ void HiScoreTable::render() // Establece la ventana del backbuffer if (mode == mhst_auto) { - window.y = std::max(8, GAME_HEIGHT - counter + 100); + window.y = std::max(8, GAMECANVAS_HEIGHT - counter + 100); } else { diff --git a/source/instructions.cpp b/source/instructions.cpp index 7325e39..124c7c3 100644 --- a/source/instructions.cpp +++ b/source/instructions.cpp @@ -36,7 +36,7 @@ Instructions::Instructions(SDL_Renderer *renderer, Screen *screen, Asset *asset, text = new Text(asset->get("smb2.png"), asset->get("smb2.txt"), renderer); // Crea un backbuffer para el renderizador - backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH, GAME_HEIGHT); + backbuffer = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); if (backbuffer == nullptr) { printf("Backbuffer could not be created!\nSDL Error: %s\n", SDL_GetError()); @@ -107,7 +107,7 @@ void Instructions::update() void Instructions::render() { // Pinta en pantalla - SDL_Rect window = {0, 0, GAME_WIDTH, GAME_HEIGHT}; + SDL_Rect window = {0, 0, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT}; SDL_Rect srcRect = {0, 0, 16, 16}; const color_t orangeColor = {0xFF, 0x7A, 0x00}; @@ -124,12 +124,12 @@ void Instructions::render() SDL_RenderClear(renderer); // Escribe el texto - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 8, lang->getText(11), 1, orangeColor, 1, shdwTxtColor); - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 24, lang->getText(12), 1, noColor, 1, shdwTxtColor); - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 34, lang->getText(13), 1, noColor, 1, shdwTxtColor); - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 48, lang->getText(14), 1, noColor, 1, shdwTxtColor); - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 58, lang->getText(15), 1, noColor, 1, shdwTxtColor); - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, 75, lang->getText(16), 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 8, lang->getText(11), 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 24, lang->getText(12), 1, noColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 34, lang->getText(13), 1, noColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 48, lang->getText(14), 1, noColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 58, lang->getText(15), 1, noColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, 75, lang->getText(16), 1, orangeColor, 1, shdwTxtColor); text->writeShadowed(84, 92, lang->getText(17), shdwTxtColor); text->writeShadowed(84, 108, lang->getText(18), shdwTxtColor); @@ -139,7 +139,7 @@ void Instructions::render() if ((mode == m_manual) && (counter % 50 > 14)) { - text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor); + text->writeDX(TXT_CENTER | TXT_COLOR | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - 12, lang->getText(22), 1, orangeColor, 1, shdwTxtColor); } // Disquito @@ -189,7 +189,7 @@ void Instructions::render() // Establece la ventana del backbuffer if (mode == m_auto) { - window.y = std::max(8, GAME_HEIGHT - counter + 100); + window.y = std::max(8, GAMECANVAS_HEIGHT - counter + 100); } else { diff --git a/source/intro.cpp b/source/intro.cpp index c6c1d9c..b9e288b 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -32,28 +32,28 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang) ss->setWidth(128); ss->setHeight(96); ss->setEnabledCounter(20); - ss->setDestX(SCREEN_CENTER_X - 64); - ss->setDestY(SCREEN_FIRST_QUARTER_Y - 24); + ss->setDestX(GAMECANVAS_CENTER_X - 64); + ss->setDestY(GAMECANVAS_FIRST_QUARTER_Y - 24); bitmaps.push_back(ss); } bitmaps.at(0)->setPosX(-128); - bitmaps.at(0)->setPosY(SCREEN_FIRST_QUARTER_Y - 24); + bitmaps.at(0)->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24); bitmaps.at(0)->setVelX(0.0f); bitmaps.at(0)->setVelY(0.0f); bitmaps.at(0)->setAccelX(0.6f); bitmaps.at(0)->setAccelY(0.0f); bitmaps.at(0)->setSpriteClip(0, 0, 128, 96); - bitmaps.at(1)->setPosX(GAME_WIDTH); - bitmaps.at(1)->setPosY(SCREEN_FIRST_QUARTER_Y - 24); + bitmaps.at(1)->setPosX(GAMECANVAS_WIDTH); + bitmaps.at(1)->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24); bitmaps.at(1)->setVelX(-1.0f); bitmaps.at(1)->setVelY(0.0f); bitmaps.at(1)->setAccelX(-0.3f); bitmaps.at(1)->setAccelY(0.0f); bitmaps.at(1)->setSpriteClip(128, 0, 128, 96); - bitmaps.at(2)->setPosX(SCREEN_CENTER_X - 64); + bitmaps.at(2)->setPosX(GAMECANVAS_CENTER_X - 64); bitmaps.at(2)->setPosY(-96); bitmaps.at(2)->setVelX(0.0f); bitmaps.at(2)->setVelY(3.0f); @@ -62,15 +62,15 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang) bitmaps.at(2)->setSpriteClip(0, 96, 128, 96); bitmaps.at(2)->setEnabledCounter(250); - bitmaps.at(3)->setPosX(SCREEN_CENTER_X - 64); - bitmaps.at(3)->setPosY(GAME_HEIGHT); + bitmaps.at(3)->setPosX(GAMECANVAS_CENTER_X - 64); + bitmaps.at(3)->setPosY(GAMECANVAS_HEIGHT); bitmaps.at(3)->setVelX(0.0f); bitmaps.at(3)->setVelY(-0.7f); bitmaps.at(3)->setAccelX(0.0f); bitmaps.at(3)->setAccelY(0.0f); bitmaps.at(3)->setSpriteClip(128, 96, 128, 96); - bitmaps.at(4)->setPosX(SCREEN_CENTER_X - 64); + bitmaps.at(4)->setPosX(GAMECANVAS_CENTER_X - 64); bitmaps.at(4)->setPosY(-96); bitmaps.at(4)->setVelX(0.0f); bitmaps.at(4)->setVelY(3.0f); @@ -78,8 +78,8 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang) bitmaps.at(4)->setAccelY(0.3f); bitmaps.at(4)->setSpriteClip(0, 192, 128, 96); - bitmaps.at(5)->setPosX(GAME_WIDTH); - bitmaps.at(5)->setPosY(SCREEN_FIRST_QUARTER_Y - 24); + bitmaps.at(5)->setPosX(GAMECANVAS_WIDTH); + bitmaps.at(5)->setPosY(GAMECANVAS_FIRST_QUARTER_Y - 24); bitmaps.at(5)->setVelX(-0.7f); bitmaps.at(5)->setVelY(0.0f); bitmaps.at(5)->setAccelX(0.0f); @@ -92,7 +92,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang) { Writer *w = new Writer(text); w->setPosX(BLOCK * 0); - w->setPosY(GAME_HEIGHT - (BLOCK * 6)); + w->setPosY(GAMECANVAS_HEIGHT - (BLOCK * 6)); w->setKerning(-1); w->setEnabled(false); w->setEnabledCounter(180); @@ -137,7 +137,7 @@ Intro::Intro(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang) for (auto text : texts) { - text->center(SCREEN_CENTER_X); + text->center(GAMECANVAS_CENTER_X); } } diff --git a/source/title.cpp b/source/title.cpp index 57856c8..f4bc589 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -186,8 +186,8 @@ void Title::init() // Coloca la ventana que recorre el mosaico de fondo de manera que coincida con el mosaico que hay pintado en el titulo al iniciar backgroundWindow.x = 128; backgroundWindow.y = 96; - backgroundWindow.w = GAME_WIDTH; - backgroundWindow.h = GAME_HEIGHT; + backgroundWindow.w = GAMECANVAS_WIDTH; + backgroundWindow.h = GAMECANVAS_HEIGHT; // Inicializa los valores del vector con los valores del seno for (int i = 0; i < 360; ++i) @@ -623,7 +623,7 @@ void Title::render() crisisBitmap->render(); // Texto con el copyright y versión - text2->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, GAME_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor); + text2->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, GAMECANVAS_HEIGHT - (BLOCK * 2), TEXT_COPYRIGHT, 1, noColor, 1, shdwTxtColor); } if (menuVisible == true) @@ -637,7 +637,7 @@ void Title::render() // PRESS ANY KEY! if ((counter % 50 > 14) && (menuVisible == false)) { - text1->writeDX(TXT_CENTER | TXT_SHADOW, SCREEN_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor); + text1->writeDX(TXT_CENTER | TXT_SHADOW, GAMECANVAS_CENTER_X, PLAY_AREA_THIRD_QUARTER_Y + BLOCK, lang->getText(23), 1, noColor, 1, shdwTxtColor); } // Fade @@ -919,8 +919,8 @@ void Title::updateMenuLabels() menu.options->setItemCaption(i, lang->getText(10)); // CANCEL // Recoloca el menu de opciones - menu.options->centerMenuOnX(SCREEN_CENTER_X); - menu.options->centerMenuOnY(SCREEN_CENTER_Y); + menu.options->centerMenuOnX(GAMECANVAS_CENTER_X); + menu.options->centerMenuOnY(GAMECANVAS_CENTER_Y); menu.options->centerMenuElementsOnX(); // Establece las etiquetas del menu de titulo @@ -930,7 +930,7 @@ void Title::updateMenuLabels() menu.title->setItemCaption(3, lang->getText(3)); // QUIT // Recoloca el menu de titulo - menu.title->centerMenuOnX(SCREEN_CENTER_X); + menu.title->centerMenuOnX(GAMECANVAS_CENTER_X); menu.title->centerMenuElementsOnX(); // Establece las etiquetas del menu de seleccion de jugador @@ -938,7 +938,7 @@ void Title::updateMenuLabels() menu.playerSelect->setItemCaption(3, lang->getText(40)); // BACK // Recoloca el menu de selección de jugador - menu.playerSelect->centerMenuOnX(SCREEN_CENTER_X); + menu.playerSelect->centerMenuOnX(GAMECANVAS_CENTER_X); menu.playerSelect->centerMenuElementsOnX(); } @@ -1062,7 +1062,7 @@ bool Title::updatePlayerInputs(int numPlayer) void Title::createTiledBackground() { // Crea la textura para el mosaico de fondo - background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAME_WIDTH * 2, GAME_HEIGHT * 2); + background = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, GAMECANVAS_WIDTH * 2, GAMECANVAS_HEIGHT * 2); if (background == nullptr) { printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError());