diff --git a/data/room/05.room b/data/room/05.room index 77af046..d36f92b 100644 --- a/data/room/05.room +++ b/data/room/05.room @@ -1,6 +1,6 @@ name=sigmasua bgColor=black -border=blue +border=cyan tileset=standard.png roomUp=03.room roomDown=0 diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index 030d15d..12cc56e 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -113,11 +113,12 @@ void ScoreBoard::render() // Escribe los textos const std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + clock.separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10); const std::string itemsTxt = std::to_string(board->items / 100) + std::to_string((board->items % 100) / 10) + std::to_string(board->items % 10); - const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10); this->text->writeColored(BLOCK, line1, "Items collected ", stringToColor("yellow")); this->text->writeColored(17 * BLOCK, line1, itemsTxt, stringToColor("bright_blue")); this->text->writeColored(20 * BLOCK, line1, " Time ", stringToColor("yellow")); this->text->writeColored(26 * BLOCK, line1, timeTxt, stringToColor("bright_blue")); + + const std::string roomsTxt = std::to_string(board->rooms / 100) + std::to_string((board->rooms % 100) / 10) + std::to_string(board->rooms % 10); this->text->writeColored(22 * BLOCK, line2, "Rooms", stringToColor("yellow")); this->text->writeColored(28 * BLOCK, line2, roomsTxt, stringToColor("bright_blue")); } diff --git a/source/screen.cpp b/source/screen.cpp index 9f825c1..33af512 100644 --- a/source/screen.cpp +++ b/source/screen.cpp @@ -13,17 +13,20 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, options_t *options, i gameCanvasWidth = gameInternalResX; gameCanvasHeight = gameInternalResY; - // Establece el modo de video - setVideoMode(options->fullScreenMode); - // Define el color del borde para el modo de pantalla completa borderColor = {0x00, 0x00, 0x00}; + borderEnabled = true; + borderWidth = 0.1f; + borderHeight = 0.1f; // Crea la textura donde se dibujan los graficos del juego gameCanvas = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, gameCanvasWidth, gameCanvasHeight); if (gameCanvas == NULL) printf("TitleSurface could not be created!\nSDL Error: %s\n", SDL_GetError()); + // Establece el modo de video + setVideoMode(options->fullScreenMode); + // Calcula los anclajes anchor.left = 0; anchor.right = gameCanvasWidth; @@ -78,9 +81,21 @@ void Screen::setVideoMode(int fullScreenMode) // Si está activo el modo ventana quita el borde if (fullScreenMode == 0) { - screenWidth = gameCanvasWidth; - screenHeight = gameCanvasHeight; - dest = {0, 0, gameCanvasWidth, gameCanvasHeight}; + if (borderEnabled) + { + const int incWidth = gameCanvasWidth * borderWidth; + const int incHeight = gameCanvasHeight * borderHeight; + screenWidth = gameCanvasWidth + incWidth; + screenHeight = gameCanvasHeight + incHeight; + dest = {0 + (incWidth / 2), 0 + (incHeight / 2), gameCanvasWidth, gameCanvasHeight}; + } + + else + { + screenWidth = gameCanvasWidth; + screenHeight = gameCanvasHeight; + dest = {0, 0, gameCanvasWidth, gameCanvasHeight}; + } // Modifica el tamaño del renderizador y de la ventana SDL_RenderSetLogicalSize(renderer, screenWidth, screenHeight); @@ -171,4 +186,24 @@ void Screen::setBorderColor(color_t color) void Screen::setBlendMode(SDL_BlendMode blendMode) { SDL_SetRenderDrawBlendMode(renderer, blendMode); +} + +// Establece el tamaño del borde +void Screen::setBorderSize(float w, float h) +{ + borderWidth = w; + borderHeight = h; +} + +// Establece si se ha de ver el borde en el modo ventana +void Screen::setBorderEnabled(bool value) +{ + borderEnabled = value; +} + +// Cambia entre borde visible y no visible +void Screen::switchBorder() +{ + borderEnabled = !borderEnabled; + setVideoMode(0); } \ No newline at end of file diff --git a/source/screen.h b/source/screen.h index 22c524e..f36b646 100644 --- a/source/screen.h +++ b/source/screen.h @@ -32,6 +32,9 @@ private: anchor_t anchor; // Variable con los anclajes de la pantalla SDL_Rect dest; // Coordenadas donde se va a dibujar la textura del juego sobre la pantalla o ventana color_t borderColor; // Color del borde añadido a la textura de juego para rellenar la pantalla + bool borderEnabled; // Indica si ha de mostrar el borde en el modo de ventana + float borderWidth; // Porcentaje de borde que se añade a lo ancho + float borderHeight; // Porcentaje de borde que se añade a lo alto public: // Constructor @@ -63,6 +66,15 @@ public: // Cambia el tipo de mezcla void setBlendMode(SDL_BlendMode blendMode); + + // Establece el tamaño del borde + void setBorderSize(float w, float h); + + // Establece si se ha de ver el borde en el modo ventana + void setBorderEnabled(bool value); + + // Cambia entre borde visible y no visible + void switchBorder(); }; #endif diff --git a/todo.txt b/todo.txt index f6dc85f..e1cc4c1 100644 --- a/todo.txt +++ b/todo.txt @@ -22,9 +22,9 @@ x (A) Poner la info de debug con la tipografia adecuada {cm:2022-08-30} x (A) El modo debug debe pintar la rejilla {cm:2022-08-30} x (A) Tecla F para pasar a pantalla completa {cm:2022-08-30} x (A) Tecla + y - para cambiar tamaño de ventana. O control F1 a F4 {cm:2022-08-30} -(A) Poner en el marcador el indicador de si esta sonando la música -(A) Poner en el marcador el numero de habitaciones visitadas -(A) Los textos del marcador de colores +x (A) Poner en el marcador el indicador de si esta sonando la música +x (A) Poner en el marcador el numero de habitaciones visitadas +x (A) Los textos del marcador de colores x (A) Añadir a cada habitación el color del borde x (A) Añadir a cada habitación el color del nombre de la habitación