From 8616c3e1656d6661a414df015d9118e9735e981c Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Tue, 30 Aug 2022 17:31:33 +0200 Subject: [PATCH] Actualizada la clase screen con nuevos procedimientos --- source/director.cpp | 1 + source/game.cpp | 58 ++++++++++++++++++++++++++------------------- source/game.h | 3 --- source/screen.cpp | 31 +++++++++++++++++++++++- source/screen.h | 9 +++++++ todo.md | 10 ++++++-- 6 files changed, 81 insertions(+), 31 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 5a0064d..ae0edff 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -42,6 +42,7 @@ Director::Director(std::string path) input = new Input(asset->get("gamecontrollerdb.txt")); initInput(); screen = new Screen(window, renderer, options, GAMECANVAS_WIDTH, GAMECANVAS_HEIGHT); + screen->setBorderColor(borderColor); } Director::~Director() diff --git a/source/game.cpp b/source/game.cpp index 3bcd7d9..2a2bee2 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -87,16 +87,46 @@ void Game::update() section.name = SECTION_PROG_QUIT; break; } + else if ((eventHandler->type == SDL_KEYDOWN) and (eventHandler->key.repeat == 0)) + { + switch (eventHandler->key.keysym.scancode) + { + case SDL_SCANCODE_D: + debug = !debug; + break; + + case SDL_SCANCODE_F: + screen->switchVideoMode(); + break; + + case SDL_SCANCODE_F1: + screen->setWindowSize(1); + break; + + case SDL_SCANCODE_F2: + screen->setWindowSize(2); + break; + + case SDL_SCANCODE_F3: + screen->setWindowSize(3); + break; + + case SDL_SCANCODE_F4: + screen->setWindowSize(4); + break; + } + } } room->update(); - player->update(); - checkPlayerAndWalls(); // Debe ir detras del player update, por si se ha metido en algun muro + { + player->update(); + checkPlayerAndWalls(); + } // Debe ir detras del player update, por si se ha metido en algun muro checkPlayerOnBorder(); checkPlayerOnFloor(); checkPlayerAndItems(); checkPlayerAndEnemies(); - checkInput(); } } @@ -144,28 +174,6 @@ void Game::render() screen->blit(); } -// Comprueba la entrada - -void Game::checkInput() -{ - /* - if (input->checkInput(INPUT_UP, REPEAT_FALSE)) - changeRoom(room->getRoomUp()); - - if (input->checkInput(INPUT_DOWN, REPEAT_FALSE)) - changeRoom(room->getRoomDown()); - - if (input->checkInput(INPUT_LEFT, REPEAT_FALSE)) - changeRoom(room->getRoomLeft()); - - if (input->checkInput(INPUT_RIGHT, REPEAT_FALSE)) - changeRoom(room->getRoomRight()); - */ - - if (input->checkInput(INPUT_BUTTON_2, REPEAT_FALSE)) - debug = !debug; -} - // Cambia de habitación bool Game::changeRoom(std::string file) { diff --git a/source/game.h b/source/game.h index 4767b24..7916f26 100644 --- a/source/game.h +++ b/source/game.h @@ -43,9 +43,6 @@ private: // Pinta los objetos en pantalla void render(); - // Comprueba la entrada y actua - void checkInput(); - // Cambia de habitación bool changeRoom(std::string file); diff --git a/source/screen.cpp b/source/screen.cpp index feb1b15..1c8aee7 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -89,7 +89,7 @@ void Screen::setVideoMode(int fullScreenMode) } // Si está activo el modo de pantalla completa añade el borde - if (fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP) + else if (fullScreenMode == SDL_WINDOW_FULLSCREEN_DESKTOP) { // Obten el alto y el ancho de la ventana SDL_GetWindowSize(window, &screenWidth, &screenHeight); @@ -137,4 +137,33 @@ void Screen::setVideoMode(int fullScreenMode) // Modifica el tamaño del renderizador SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight); } + + // Actualiza el valor de la variable + options->fullScreenMode = fullScreenMode; +} + +// Camibia entre pantalla completa y ventana +void Screen::switchVideoMode() +{ + if (options->fullScreenMode == 0) + { + setVideoMode(SDL_WINDOW_FULLSCREEN_DESKTOP); + } + else + { + setVideoMode(0); + } +} + +// Cambia el tamaño de la ventana +void Screen::setWindowSize(int size) +{ + options->windowSize = size; + setVideoMode(0); +} + +// Cambia el color del borde +void Screen::setBorderColor(color_t color) +{ + borderColor = color; } \ No newline at end of file diff --git a/source/screen.h b/source/screen.h index 113d21b..5c15402 100644 --- a/source/screen.h +++ b/source/screen.h @@ -51,6 +51,15 @@ public: // Establece el modo de video void setVideoMode(int fullScreenMode); + + // Camibia entre pantalla completa y ventana + void switchVideoMode(); + + // Cambia el tamaño de la ventana + void setWindowSize(int size); + + // Cambia el color del borde + void setBorderColor(color_t color); }; #endif diff --git a/todo.md b/todo.md index bec5464..b118ae0 100644 --- a/todo.md +++ b/todo.md @@ -7,12 +7,18 @@ (A) Decidir un diseño para qué sucede en caso de morir: Recordar el punto por donde se entró al mapa y la velocidad en el eje X/Y que llevaba el personaje, crear puntos de reaparicion en las habitaciones, etc {cm:2022-08-29} En el Jet Set Willy el juego recuerda la posicion y el momento. En las Tres Luces de Glaurung solo la posición. Se va a optar por seguir el diseño del Jet Set Willy {cm:2022-08-29} (A) Crear tiles que maten {cm:2022-08-29} + (A) Crear tiles que deslicen, (no tipo hielo sino cinta) (A) Tiles animados (A) Crear ascensores (A) Enemigos de diferente tamaño -(A) Color de los items -(A) Temporizador de inicio de los items +(A) Color de los items al estilo jet set willy de amstrad, que brillan con dos colores +(A) Temporizador de inicio de los items, para poder hacer que brillen a distinto ritmo. Esto es incompatible con lo anterior + +(A) Poner la info de debug con la tipografia adecuada +(A) El modo debug debe pintar la rejilla +(A) Tecla F para pasar a pantalla completa +(A) Tecla + y - para cambiar tamaño de ventana. O control F1 a F4 ## TEMAS