From c7109a46cd91b7b9c0ff95bcad0d36bab8625dbf Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 7 Oct 2022 13:56:51 +0200 Subject: [PATCH] =?UTF-8?q?Peque=C3=B1os=20ajustes=20y=20detalles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/config/config.bin | Bin 24 -> 24 bytes source/balloon.cpp | 28 +++++++------- source/director.cpp | 3 -- source/game.cpp | 82 ++++++++++++++++++++++++++++++++++++++++- source/game.h | 7 +++- source/intro.cpp | 31 ++++++++++++++++ source/player.cpp | 9 +++++ source/player.h | 21 ++--------- source/title.cpp | 46 ++++++++++++++++++++++- source/title.h | 3 ++ todo.txt | 18 +++++---- 11 files changed, 200 insertions(+), 48 deletions(-) diff --git a/data/config/config.bin b/data/config/config.bin index 0f82916333746e88a84f06ffde6f193df3f6775c..b64371aac7120ad1b9b37415ca6f790b2322d6ac 100644 GIT binary patch literal 24 XcmZQzU|?WoWMBXy5CNnPfEbJb1r7kp literal 24 YcmZQzU|?WoWMp6j(m(=89RM*H0RgetTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni))); sprite->render(); - //if (kind == POWER_BALL) - //{ - // Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); - // sp->setSpriteClip(407, 0, 37, 37); - // sp->render(); - // delete sp; - //} + if (kind == POWER_BALL) + { + Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); + sp->setSpriteClip(407, 0, 37, 37); + sp->render(); + delete sp; + } sprite->getTexture()->setAlpha(255); } else { sprite->render(); - //if (kind == POWER_BALL and !popping) - //{ - // Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); - // sp->setSpriteClip(407, 0, 37, 37); - // sp->render(); - // delete sp; - //} + if (kind == POWER_BALL and !popping) + { + Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); + sp->setSpriteClip(407, 0, 37, 37); + sp->render(); + delete sp; + } } } } diff --git a/source/director.cpp b/source/director.cpp index 487478b..11c9b17 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -7,13 +7,10 @@ // Constructor Director::Director(std::string path) { - // Inicializa variables section.name = PROG_SECTION_GAME; section.subsection = GAME_SECTION_PLAY_1P; - section.name = PROG_SECTION_INTRO; - // Crea el objeto que controla los ficheros de recursos asset = new Asset(path.substr(0, path.find_last_of("\\/")) + "/../"); diff --git a/source/game.cpp b/source/game.cpp index f188c6e..0085b5a 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -188,7 +188,7 @@ void Game::init() if (numPlayers == 1) { - Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, player2Textures, playerAnimations); + Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, player1Textures, playerAnimations); players.push_back(player); } @@ -206,16 +206,21 @@ void Game::init() case DIFFICULTY_EASY: defaultEnemySpeed = BALLOON_SPEED_1; difficultyScoreMultiplier = 0.5f; + difficultyColor = {75, 105, 47}; + pauseMenu->setSelectorColor(difficultyColor, 255); break; case DIFFICULTY_NORMAL: defaultEnemySpeed = BALLOON_SPEED_1; difficultyScoreMultiplier = 1.0f; + difficultyColor = {46, 63, 71}; break; case DIFFICULTY_HARD: defaultEnemySpeed = BALLOON_SPEED_5; difficultyScoreMultiplier = 1.5f; + difficultyColor = {118, 66, 138}; + pauseMenu->setSelectorColor(difficultyColor, 255); break; default: @@ -1547,9 +1552,11 @@ std::string Game::updateScoreText(Uint32 num) void Game::renderScoreBoard() { // Dibuja el fondo del marcador - SDL_SetRenderDrawColor(renderer, 46, 63, 71, 255); + SDL_SetRenderDrawColor(renderer, difficultyColor.r, difficultyColor.g, difficultyColor.b, 255); SDL_Rect rect = {0, 160, 256, 32}; SDL_RenderFillRect(renderer, &rect); + + // Dibuja la linea que separa el marcador de la zona de juego SDL_SetRenderDrawColor(renderer, 13, 26, 43, 255); SDL_RenderDrawLine(renderer, 0, 160, 255, 160); @@ -3565,6 +3572,31 @@ void Game::checkEventHandler() { switch (eventHandler->key.keysym.scancode) { + case SDL_SCANCODE_F: + screen->switchVideoMode(); + reloadTextures(); + break; + + case SDL_SCANCODE_F1: + screen->setWindowSize(1); + reloadTextures(); + break; + + case SDL_SCANCODE_F2: + screen->setWindowSize(2); + reloadTextures(); + break; + + case SDL_SCANCODE_F3: + screen->setWindowSize(3); + reloadTextures(); + break; + + case SDL_SCANCODE_F4: + screen->setWindowSize(4); + reloadTextures(); + break; + case SDL_SCANCODE_P: createPowerBall(); break; @@ -3573,6 +3605,20 @@ void Game::checkEventHandler() stopAllBalloons(200); break; + case SDL_SCANCODE_I: + static bool toogle = true; + if (toogle) + { + players.at(0)->setPlayerTextures(player1Textures); + toogle = !toogle; + } + else + { + players.at(0)->setPlayerTextures(player2Textures); + toogle = !toogle; + } + break; + default: break; } @@ -3629,4 +3675,36 @@ void Game::deleteAllVectorObjects() delete smartSprite; }; smartSprites.clear(); +} + +// Recarga las texturas +void Game::reloadTextures() +{ + for (auto texture : itemTextures) + { + texture->reLoad(); + } + + for (auto texture : balloonTextures) + { + texture->reLoad(); + } + + for (auto texture : player1Textures) + { + texture->reLoad(); + } + + for (auto texture : player2Textures) + { + texture->reLoad(); + } + + bulletTexture->reLoad(); + gameBuildingsTexture->reLoad(); + gameCloudsTexture->reLoad(); + gameGrassTexture->reLoad(); + gamePowerMeterTexture->reLoad(); + gameSkyColorsTexture->reLoad(); + gameTextTexture->reLoad(); } \ No newline at end of file diff --git a/source/game.h b/source/game.h index 6d1558e..e29221b 100644 --- a/source/game.h +++ b/source/game.h @@ -220,13 +220,13 @@ private: int gameCompletedCounter; // Contador para el tramo final, cuando se ha completado la partida y ya no aparecen más enemigos Uint8 difficulty; // Dificultad del juego float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad + color_t difficultyColor; // Color asociado a la dificultad struct options_t *options; // Variable con todas las variables de las opciones del programa Uint8 onePlayerControl; // Variable para almacenar el valor de las opciones enemyFormation_t enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas enemyPool_t enemyPool[10]; // Variable con los diferentes conjuntos de formaciones enemigas Uint8 lastStageReached; // Contiene el numero de la última pantalla que se ha alcanzado - - demo_t demo; // Variable con todas las variables relacionadas con el modo demo + demo_t demo; // Variable con todas las variables relacionadas con el modo demo // Actualiza el juego void update(); @@ -486,6 +486,9 @@ private: // Elimina todos los objetos contenidos en vectores void deleteAllVectorObjects(); + // Recarga las texturas + void reloadTextures(); + public: // Constructor Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options); diff --git a/source/intro.cpp b/source/intro.cpp index dd8bf30..738076f 100644 --- a/source/intro.cpp +++ b/source/intro.cpp @@ -190,6 +190,37 @@ void Intro::checkEventHandler() JA_StopMusic(); section.name = PROG_SECTION_TITLE; section.subsection = TITLE_SECTION_1; + + switch (eventHandler->key.keysym.scancode) + { + case SDL_SCANCODE_F: + screen->switchVideoMode(); + texture->reLoad(); + break; + + case SDL_SCANCODE_F1: + screen->setWindowSize(1); + texture->reLoad(); + break; + + case SDL_SCANCODE_F2: + screen->setWindowSize(2); + texture->reLoad(); + break; + + case SDL_SCANCODE_F3: + screen->setWindowSize(3); + texture->reLoad(); + break; + + case SDL_SCANCODE_F4: + screen->setWindowSize(4); + texture->reLoad(); + break; + + default: + break; + } } } } diff --git a/source/player.cpp b/source/player.cpp index 17b6485..301deda 100644 --- a/source/player.cpp +++ b/source/player.cpp @@ -595,4 +595,13 @@ void Player::updatePowerUpHeadOffset() } } } +} + +// Pone las texturas del jugador +void Player::setPlayerTextures(std::vector texture) +{ + headSprite->setTexture(texture.at(0)); + bodySprite->setTexture(texture.at(1)); + legsSprite->setTexture(texture.at(2)); + deathSprite->setTexture(texture.at(3)); } \ No newline at end of file diff --git a/source/player.h b/source/player.h index f30de63..0499b53 100644 --- a/source/player.h +++ b/source/player.h @@ -23,24 +23,6 @@ #define PLAYER_STATUS_FIRING_RIGHT 2 #define PLAYER_STATUS_FIRING_NO 3 -#define PLAYER_ANIMATION_LEGS_WALKING_LEFT 0 -#define PLAYER_ANIMATION_LEGS_WALKING_RIGHT 1 -#define PLAYER_ANIMATION_LEGS_WALKING_STOP 2 - -#define PLAYER_ANIMATION_BODY_WALKING_LEFT 0 -#define PLAYER_ANIMATION_BODY_FIRING_LEFT 1 -#define PLAYER_ANIMATION_BODY_WALKING_RIGHT 2 -#define PLAYER_ANIMATION_BODY_FIRING_RIGHT 3 -#define PLAYER_ANIMATION_BODY_WALKING_STOP 4 -#define PLAYER_ANIMATION_BODY_FIRING_UP 5 - -#define PLAYER_ANIMATION_HEAD_WALKING_LEFT 0 -#define PLAYER_ANIMATION_HEAD_FIRING_LEFT 1 -#define PLAYER_ANIMATION_HEAD_WALKING_RIGHT 2 -#define PLAYER_ANIMATION_HEAD_FIRING_RIGHT 3 -#define PLAYER_ANIMATION_HEAD_WALKING_STOP 4 -#define PLAYER_ANIMATION_HEAD_FIRING_UP 5 - // Variables del jugador #define PLAYER_INVULNERABLE_COUNTER 200 #define PLAYER_POWERUP_COUNTER 1500 @@ -114,6 +96,9 @@ public: // Pinta el jugador en pantalla void render(); + // Pone las texturas del jugador + void setPlayerTextures(std::vector texture); + // Actua en consecuencia de la entrada recibida void setInput(Uint8 input); diff --git a/source/title.cpp b/source/title.cpp index 52d614f..7356225 100644 --- a/source/title.cpp +++ b/source/title.cpp @@ -10,7 +10,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, this->asset = asset; this->options = options; this->lang = lang; - + this->section = section; // Reserva memoria para los punteros propios @@ -616,6 +616,40 @@ void Title::checkEventHandler() break; } + else if (eventHandler->type == SDL_KEYDOWN && eventHandler->key.repeat == 0) + { + switch (eventHandler->key.keysym.scancode) + { + case SDL_SCANCODE_F: + screen->switchVideoMode(); + reloadTextures(); + break; + + case SDL_SCANCODE_F1: + screen->setWindowSize(1); + reloadTextures(); + break; + + case SDL_SCANCODE_F2: + screen->setWindowSize(2); + reloadTextures(); + break; + + case SDL_SCANCODE_F3: + screen->setWindowSize(3); + reloadTextures(); + break; + + case SDL_SCANCODE_F4: + screen->setWindowSize(4); + reloadTextures(); + break; + + default: + break; + } + } + if (section.subsection == TITLE_SECTION_3) { // Si se pulsa alguna tecla durante la tercera sección del titulo if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP)) @@ -1000,4 +1034,14 @@ void Title::checkInputDevices() temp.deviceType = INPUT_USE_KEYBOARD; availableInputDevices.push_back(temp); printf("Device %i:\t%s\n\n", (int)availableInputDevices.size(), temp.name.c_str()); +} + +// Recarga las texturas +void Title::reloadTextures() +{ + dustTexture->reLoad(); + coffeeTexture->reLoad(); + crisisTexture->reLoad(); + gradientTexture->reLoad(); + createTiledBackground(); } \ No newline at end of file diff --git a/source/title.h b/source/title.h index aa00e4e..b2b8e54 100644 --- a/source/title.h +++ b/source/title.h @@ -130,6 +130,9 @@ private: // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones void checkInputDevices(); + // Recarga las texturas + void reloadTextures(); + public: // Constructor Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t section); diff --git a/todo.txt b/todo.txt index 62c3ee9..3879b53 100644 --- a/todo.txt +++ b/todo.txt @@ -6,10 +6,10 @@ x la powerball deja la mascara al explotarlas x los menus de pausa y game over falta poner bien los textos x cuando continuas la partida sigues muerto poder elegir el personaje para jugar -arreglar los smart sprites de muerte y de perder el cafe -arreglar los items de las instrucciones -que cicle la musica en el titulo, demo, instrucciones -que guarde el progreso del juego +x arreglar los smart sprites de muerte y de perder el cafe +x arreglar los items de las instrucciones +x que cicle la musica en el titulo, demo, instrucciones +NO que guarde el progreso del juego que aumente la velocidad de las nubes conforme avanzas retocar un poco la distancia entre los cambios de color del cielo, se llega al oscuro muy pronto x las balas deberian llegar a salir de la pantalla @@ -17,7 +17,9 @@ x hacer desaparecer los accesos a disco en el juego. cargar todos los recursos p x la powerball se para con el reloj y sigue rodando x acelerar la animacion de disparar recto x no pone la animacion corecta al no disparar con el powerup -que grite "yiiijaa!" o algo parecido al coger la maquina de cafe -o que diga DIMONIS! en un globo de texto que se evapore -podrian salir comentarios aleatoriamente o con ciertos eventos (falta ver si no estorbará) -que se vea el nivel de dificultad \ No newline at end of file +NO que grite "yiiijaa!" o algo parecido al coger la maquina de cafe +NO o que diga DIMONIS! en un globo de texto que se evapore +NO podrian salir comentarios aleatoriamente o con ciertos eventos (falta ver si no estorbará) +x que se vea el nivel de dificultad +poner un dibujito en la pantalla de game over al terminar el juego +y quizas otro en la propia pantalla de game over \ No newline at end of file