Pequeños ajustes y detalles

This commit is contained in:
2022-10-07 13:56:51 +02:00
parent bb20522172
commit c7109a46cd
11 changed files with 200 additions and 48 deletions

Binary file not shown.

View File

@@ -323,26 +323,26 @@ void Balloon::render()
// Aplica alpha blending // Aplica alpha blending
sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni))); sprite->getTexture()->setAlpha(255 - (int)((float)creationCounter * (255.0f / (float)creationCounterIni)));
sprite->render(); sprite->render();
//if (kind == POWER_BALL) if (kind == POWER_BALL)
//{ {
// Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
// sp->setSpriteClip(407, 0, 37, 37); sp->setSpriteClip(407, 0, 37, 37);
// sp->render(); sp->render();
// delete sp; delete sp;
//} }
sprite->getTexture()->setAlpha(255); sprite->getTexture()->setAlpha(255);
} }
else else
{ {
sprite->render(); sprite->render();
//if (kind == POWER_BALL and !popping) if (kind == POWER_BALL and !popping)
//{ {
// Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer()); Sprite *sp = new Sprite(sprite->getRect(), sprite->getTexture(), sprite->getRenderer());
// sp->setSpriteClip(407, 0, 37, 37); sp->setSpriteClip(407, 0, 37, 37);
// sp->render(); sp->render();
// delete sp; delete sp;
//} }
} }
} }
} }

View File

@@ -7,13 +7,10 @@
// Constructor // Constructor
Director::Director(std::string path) Director::Director(std::string path)
{ {
// Inicializa variables // Inicializa variables
section.name = PROG_SECTION_GAME; section.name = PROG_SECTION_GAME;
section.subsection = GAME_SECTION_PLAY_1P; section.subsection = GAME_SECTION_PLAY_1P;
section.name = PROG_SECTION_INTRO;
// Crea el objeto que controla los ficheros de recursos // Crea el objeto que controla los ficheros de recursos
asset = new Asset(path.substr(0, path.find_last_of("\\/")) + "/../"); asset = new Asset(path.substr(0, path.find_last_of("\\/")) + "/../");

View File

@@ -188,7 +188,7 @@ void Game::init()
if (numPlayers == 1) 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); players.push_back(player);
} }
@@ -206,16 +206,21 @@ void Game::init()
case DIFFICULTY_EASY: case DIFFICULTY_EASY:
defaultEnemySpeed = BALLOON_SPEED_1; defaultEnemySpeed = BALLOON_SPEED_1;
difficultyScoreMultiplier = 0.5f; difficultyScoreMultiplier = 0.5f;
difficultyColor = {75, 105, 47};
pauseMenu->setSelectorColor(difficultyColor, 255);
break; break;
case DIFFICULTY_NORMAL: case DIFFICULTY_NORMAL:
defaultEnemySpeed = BALLOON_SPEED_1; defaultEnemySpeed = BALLOON_SPEED_1;
difficultyScoreMultiplier = 1.0f; difficultyScoreMultiplier = 1.0f;
difficultyColor = {46, 63, 71};
break; break;
case DIFFICULTY_HARD: case DIFFICULTY_HARD:
defaultEnemySpeed = BALLOON_SPEED_5; defaultEnemySpeed = BALLOON_SPEED_5;
difficultyScoreMultiplier = 1.5f; difficultyScoreMultiplier = 1.5f;
difficultyColor = {118, 66, 138};
pauseMenu->setSelectorColor(difficultyColor, 255);
break; break;
default: default:
@@ -1547,9 +1552,11 @@ std::string Game::updateScoreText(Uint32 num)
void Game::renderScoreBoard() void Game::renderScoreBoard()
{ {
// Dibuja el fondo del marcador // 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_Rect rect = {0, 160, 256, 32};
SDL_RenderFillRect(renderer, &rect); SDL_RenderFillRect(renderer, &rect);
// Dibuja la linea que separa el marcador de la zona de juego
SDL_SetRenderDrawColor(renderer, 13, 26, 43, 255); SDL_SetRenderDrawColor(renderer, 13, 26, 43, 255);
SDL_RenderDrawLine(renderer, 0, 160, 255, 160); SDL_RenderDrawLine(renderer, 0, 160, 255, 160);
@@ -3565,6 +3572,31 @@ void Game::checkEventHandler()
{ {
switch (eventHandler->key.keysym.scancode) 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: case SDL_SCANCODE_P:
createPowerBall(); createPowerBall();
break; break;
@@ -3573,6 +3605,20 @@ void Game::checkEventHandler()
stopAllBalloons(200); stopAllBalloons(200);
break; 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: default:
break; break;
} }
@@ -3630,3 +3676,35 @@ void Game::deleteAllVectorObjects()
}; };
smartSprites.clear(); 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();
}

View File

@@ -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 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 Uint8 difficulty; // Dificultad del juego
float difficultyScoreMultiplier; // Multiplicador de puntos en función de la dificultad 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 struct options_t *options; // Variable con todas las variables de las opciones del programa
Uint8 onePlayerControl; // Variable para almacenar el valor de las opciones Uint8 onePlayerControl; // Variable para almacenar el valor de las opciones
enemyFormation_t enemyFormation[NUMBER_OF_ENEMY_FORMATIONS]; // Vector con todas las formaciones enemigas 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 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 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 // Actualiza el juego
void update(); void update();
@@ -486,6 +486,9 @@ private:
// Elimina todos los objetos contenidos en vectores // Elimina todos los objetos contenidos en vectores
void deleteAllVectorObjects(); void deleteAllVectorObjects();
// Recarga las texturas
void reloadTextures();
public: public:
// Constructor // Constructor
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options); Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, options_t *options);

View File

@@ -190,6 +190,37 @@ void Intro::checkEventHandler()
JA_StopMusic(); JA_StopMusic();
section.name = PROG_SECTION_TITLE; section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1; 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;
}
} }
} }
} }

View File

@@ -596,3 +596,12 @@ void Player::updatePowerUpHeadOffset()
} }
} }
} }
// Pone las texturas del jugador
void Player::setPlayerTextures(std::vector<LTexture *> texture)
{
headSprite->setTexture(texture.at(0));
bodySprite->setTexture(texture.at(1));
legsSprite->setTexture(texture.at(2));
deathSprite->setTexture(texture.at(3));
}

View File

@@ -23,24 +23,6 @@
#define PLAYER_STATUS_FIRING_RIGHT 2 #define PLAYER_STATUS_FIRING_RIGHT 2
#define PLAYER_STATUS_FIRING_NO 3 #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 // Variables del jugador
#define PLAYER_INVULNERABLE_COUNTER 200 #define PLAYER_INVULNERABLE_COUNTER 200
#define PLAYER_POWERUP_COUNTER 1500 #define PLAYER_POWERUP_COUNTER 1500
@@ -114,6 +96,9 @@ public:
// Pinta el jugador en pantalla // Pinta el jugador en pantalla
void render(); void render();
// Pone las texturas del jugador
void setPlayerTextures(std::vector<LTexture *> texture);
// Actua en consecuencia de la entrada recibida // Actua en consecuencia de la entrada recibida
void setInput(Uint8 input); void setInput(Uint8 input);

View File

@@ -616,6 +616,40 @@ void Title::checkEventHandler()
break; 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) if (section.subsection == TITLE_SECTION_3)
{ // Si se pulsa alguna tecla durante la tercera sección del titulo { // Si se pulsa alguna tecla durante la tercera sección del titulo
if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP)) if ((eventHandler->type == SDL_KEYUP) || (eventHandler->type == SDL_JOYBUTTONUP))
@@ -1001,3 +1035,13 @@ void Title::checkInputDevices()
availableInputDevices.push_back(temp); availableInputDevices.push_back(temp);
printf("Device %i:\t%s\n\n", (int)availableInputDevices.size(), temp.name.c_str()); 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();
}

View File

@@ -130,6 +130,9 @@ private:
// Comprueba cuantos mandos hay conectados para gestionar el menu de opciones // Comprueba cuantos mandos hay conectados para gestionar el menu de opciones
void checkInputDevices(); void checkInputDevices();
// Recarga las texturas
void reloadTextures();
public: public:
// Constructor // Constructor
Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t section); Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset, options_t *options, Lang *lang, section_t section);

View File

@@ -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 los menus de pausa y game over falta poner bien los textos
x cuando continuas la partida sigues muerto x cuando continuas la partida sigues muerto
poder elegir el personaje para jugar poder elegir el personaje para jugar
arreglar los smart sprites de muerte y de perder el cafe x arreglar los smart sprites de muerte y de perder el cafe
arreglar los items de las instrucciones x arreglar los items de las instrucciones
que cicle la musica en el titulo, demo, instrucciones x que cicle la musica en el titulo, demo, instrucciones
que guarde el progreso del juego NO que guarde el progreso del juego
que aumente la velocidad de las nubes conforme avanzas 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 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 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 la powerball se para con el reloj y sigue rodando
x acelerar la animacion de disparar recto x acelerar la animacion de disparar recto
x no pone la animacion corecta al no disparar con el powerup x no pone la animacion corecta al no disparar con el powerup
que grite "yiiijaa!" o algo parecido al coger la maquina de cafe NO que grite "yiiijaa!" o algo parecido al coger la maquina de cafe
o que diga DIMONIS! en un globo de texto que se evapore NO 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á) NO podrian salir comentarios aleatoriamente o con ciertos eventos (falta ver si no estorbará)
que se vea el nivel de dificultad 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