From add7e5201ab877258ae6f73f0bb848858e6b0c24 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 29 Aug 2022 21:07:52 +0200 Subject: [PATCH] Sustituyendo todos los defines de const.h --- source/animatedsprite.cpp | 2 +- source/director.cpp | 10 +++------- source/director.h | 6 +++--- source/game.cpp | 6 +++--- source/game.h | 2 +- source/ltexture.cpp | 2 +- source/menu.cpp | 2 +- source/movingsprite.cpp | 2 +- source/player.h | 2 +- source/room.h | 2 +- source/screen.cpp | 5 ++--- source/text.cpp | 2 +- 12 files changed, 19 insertions(+), 24 deletions(-) diff --git a/source/animatedsprite.cpp b/source/animatedsprite.cpp index a2036a0..e7dc797 100644 --- a/source/animatedsprite.cpp +++ b/source/animatedsprite.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "animatedsprite.h" // Constructor diff --git a/source/director.cpp b/source/director.cpp index a6911ae..8e1e385 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "utils.h" #include "director.h" #include @@ -41,10 +41,6 @@ Director::Director(std::string path) // Inicializa JailAudio initJailAudio(); - // Aplica las opciones - SDL_SetWindowFullscreen(window, options->fullScreenMode); - SDL_SetWindowSize(window, SCREEN_WIDTH * options->windowSize, SCREEN_HEIGHT * options->windowSize); - // Inicializa el resto de variables init(section); } @@ -122,7 +118,7 @@ bool Director::initSDL() } // Crea la ventana - window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, VIEW_WIDTH, VIEW_HEIGHT, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); + window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, options->screenWidth, options->screenHeight, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); if (window == NULL) { printf("Window could not be created!\nSDL Error: %s\n", SDL_GetError()); @@ -147,7 +143,7 @@ bool Director::initSDL() SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); // Establece el tamaño del buffer de renderizado - SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT); + SDL_RenderSetLogicalSize(renderer, options->screenWidth, options->screenHeight); // Establece el modo de mezcla SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); diff --git a/source/director.h b/source/director.h index 1117afb..7b9e3f2 100644 --- a/source/director.h +++ b/source/director.h @@ -4,7 +4,7 @@ #include "movingsprite.h" #include "text.h" #include "menu.h" -#include "const.h" + #include "jail_audio.h" #include "utils.h" #include "input.h" @@ -15,8 +15,8 @@ #define DIRECTOR_H #define WINDOW_CAPTION "JailDoctor's Dilemma" -#define GAME_WIDTH 320 -#define GAME_HEIGHT 240 +#define GAME_WIDTH 256 +#define GAME_HEIGHT 192 // Director class Director diff --git a/source/game.cpp b/source/game.cpp index 2556c4f..8512619 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -5,7 +5,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input) { // Inicia variables currentRoom = "01.room"; - spawnPoint = {2 * BLOCK, 12 * BLOCK, 0, 0, 0, STATUS_STANDING, SDL_FLIP_NONE}; + spawnPoint = {2 * 8, 12 * 8, 0, 0, 0, STATUS_STANDING, SDL_FLIP_NONE}; debug = false; // Copia los punteros @@ -26,7 +26,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input) ticksSpeed = 15; section.name = SECTION_PROG_GAME; - section.subsection = SECTION_GAME_PLAY; + section.subsection = SUBSECTION_GAME_PLAY; } Game::~Game() @@ -62,7 +62,7 @@ section_t Game::run() while (section.name == SECTION_PROG_GAME) { // Sección juego jugando - if (section.subsection == SECTION_GAME_PLAY) + if (section.subsection == SUBSECTION_GAME_PLAY) { update(); render(); diff --git a/source/game.h b/source/game.h index f70d174..4767b24 100644 --- a/source/game.h +++ b/source/game.h @@ -1,6 +1,6 @@ #pragma once #include -#include "const.h" + #include "utils.h" #include "sprite.h" #include "movingsprite.h" diff --git a/source/ltexture.cpp b/source/ltexture.cpp index 0e6fd17..8225882 100644 --- a/source/ltexture.cpp +++ b/source/ltexture.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "ltexture.h" #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" diff --git a/source/menu.cpp b/source/menu.cpp index bc6c5be..ddd7ef8 100644 --- a/source/menu.cpp +++ b/source/menu.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "menu.h" // Constructor diff --git a/source/movingsprite.cpp b/source/movingsprite.cpp index 8500651..f3d98df 100644 --- a/source/movingsprite.cpp +++ b/source/movingsprite.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "movingsprite.h" // Constructor diff --git a/source/player.h b/source/player.h index 805ff8c..1fd1209 100644 --- a/source/player.h +++ b/source/player.h @@ -1,6 +1,6 @@ #pragma once #include -#include "const.h" + #include "utils.h" #include "asset.h" #include "room.h" diff --git a/source/room.h b/source/room.h index c432273..06fc32c 100644 --- a/source/room.h +++ b/source/room.h @@ -1,6 +1,6 @@ #pragma once #include -#include "const.h" + #include "utils.h" #include "asset.h" #include "enemy.h" diff --git a/source/screen.cpp b/source/screen.cpp index 4f71934..3b33e81 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -1,5 +1,4 @@ #include "screen.h" -#include "const.h" #include #include @@ -11,8 +10,8 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options) this->renderer = renderer; this->options = options; - gameCanvasWidth = SCREEN_WIDTH; - gameCanvasHeight = SCREEN_HEIGHT; + gameCanvasWidth = 256; + gameCanvasHeight = 192; // Establece el modo de video setVideoMode(options->fullScreenMode); diff --git a/source/text.cpp b/source/text.cpp index 57695d8..e4bf037 100644 --- a/source/text.cpp +++ b/source/text.cpp @@ -1,4 +1,4 @@ -#include "const.h" + #include "text.h" #include #include