diff --git a/source/common/screen.cpp b/source/common/screen.cpp index e6454a5..1ba2352 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -44,71 +44,6 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, options notifyActive = false; } -// Crea la ventana -void Screen::createDisplay() -{ - window = SDL_CreateWindow(WINDOW_CAPTION, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth * options->windowSize, windowHeight * options->windowSize, SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI); - if (window == nullptr) - { - if (options->console) - { - std::cout << "Window could not be created!\nSDL Error: " << SDL_GetError() << std::endl; - } - } - else - { - // Crea un renderizador para la ventana. El vsync se activa en funcion de las opciones - if (options->vSync) - { - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); - } - else - { - renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); - } - - if (renderer == nullptr) - { - if (options->console) - { - std::cout << "Renderer could not be created!\nSDL Error: " << SDL_GetError() << std::endl; - } - } - else - { - // Inicializa el color de renderizado - SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0xFF); - - // Establece el tamaño del buffer de renderizado - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); - - // Establece el modo de mezcla - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_BLEND); - - // Muestra el puntero - SDL_ShowCursor(SDL_ENABLE); - - // Crea la textura donde se dibujan los graficos del juego - gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight); - if (gameCanvas == nullptr) - { - if (options->console) - { - std::cout << "TitleSurface could not be created!\nSDL Error: " << SDL_GetError() << std::endl; - } - } - } - } -} - -// Destruye la ventana -void Screen::destroyDisplay() -{ - SDL_DestroyTexture(gameCanvas); - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); -} - // Destructor Screen::~Screen() { @@ -152,12 +87,15 @@ void Screen::blit() // Establece el modo de video void Screen::setVideoMode(int videoMode) { - // Destruye la ventana - destroyDisplay(); + // Aplica el modo de video + SDL_SetWindowFullscreen(window, videoMode); // Si está activo el modo ventana quita el borde if (videoMode == 0) { + // Muestra el puntero + SDL_ShowCursor(SDL_ENABLE); + if (options->borderEnabled) { windowWidth = gameCanvasWidth + borderWidth; @@ -172,19 +110,9 @@ void Screen::setVideoMode(int videoMode) dest = {0, 0, gameCanvasWidth, gameCanvasHeight}; } - createDisplay(); - - /* - // Modifica el tamaño del renderizador y de la ventana - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); - // SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize); - - // Muestra el puntero - SDL_ShowCursor(SDL_ENABLE); - */ - - // Aplica el modo de video - SDL_SetWindowFullscreen(window, videoMode); + // Modifica el tamaño de la ventana + SDL_SetWindowSize(window, windowWidth * options->windowSize, windowHeight * options->windowSize); + SDL_SetWindowPosition(window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); } // Si está activo el modo de pantalla completa añade el borde @@ -235,10 +163,10 @@ void Screen::setVideoMode(int videoMode) dest.h = windowHeight; dest.x = dest.y = 0; } - - // Modifica el tamaño del renderizador - SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); } + + // Modifica el tamaño del renderizador + SDL_RenderSetLogicalSize(renderer, windowWidth, windowHeight); // Actualiza las opciones options->videoMode = videoMode; diff --git a/source/common/screen.h b/source/common/screen.h index c0b8bc8..9a05e5d 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -46,12 +46,6 @@ private: int spectrumFadeLenght; // Duración del fade spectrum std::vector spectrumColor; // Colores para el fade spectrum - // Crea la ventana - void createDisplay(); - - // Destruye la ventana - void destroyDisplay(); - // Inicializa las variables para el fade void iniFade(); diff --git a/source/game.cpp b/source/game.cpp index 0a1c94d..3015e0d 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -21,7 +21,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Resource *resource, Asset *as const int x = 25; const int y = 13; spawnPoint = {x * 8, y * 8, 0, 0, 0, s_standing, SDL_FLIP_HORIZONTAL}; - debug->setEnabled(true); + debug->setEnabled(false); #else currentRoom = "03.room"; const int x = 25;