Listo para lanzamiento

This commit is contained in:
2022-10-09 14:23:45 +02:00
parent 9e73f7f97d
commit f83154c062
16 changed files with 249 additions and 145 deletions

View File

@@ -115,14 +115,14 @@ D E M O
## 38 - TEXTOS DEL JUEGO ## 38 - TEXTOS DEL JUEGO
fases mes! fases mes!
## 39 - ## 39 - MENU SELECCION DE JUGADOR
- Selecciona personatge
## 40 - ## 40 - MENU SELECCION DE JUGADOR
- Enrere
## 41 - ## 41 - MENU DE PAUSA
- Menu de pausa
## 42 - ## 42 -
- -

View File

@@ -115,14 +115,14 @@ D E M O
## 38 - TEXTOS DEL JUEGO ## 38 - TEXTOS DEL JUEGO
stages left! stages left!
## 39 - ## 39 - MENU SELECCION DE JUGADOR
- Select Player
## 40 - ## 40 - MENU SELECCION DE JUGADOR
- Back
## 41 - ## 41 - MENU DE PAUSA
- Pause Menu
## 42 - ## 42 -
- -

View File

@@ -115,14 +115,14 @@ D E M O
## 38 - TEXTOS DEL JUEGO ## 38 - TEXTOS DEL JUEGO
fases mas! fases mas!
## 39 - ## 39 - MENU SELECCION DE JUGADOR
- Selecciona jugador
## 40 - ## 40 - MENU SELECCION DE JUGADOR
- Volver
## 41 - ## 41 - MENU DE PAUSA
- Menu de pausa
## 42 - ## 42 -
- -

View File

@@ -1,9 +1,8 @@
font_png=smb2.png font_png=smb2.png
font_txt=smb2.txt font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav sound_move=menu_move.wav
sound_accept=menu_select.wav
name=GAME OVER name=GAME OVER
x=0 x=0

View File

@@ -1,9 +1,8 @@
font_png=smb2.png font_png=smb2.png
font_txt=smb2.txt font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav sound_move=menu_move.wav
sound_accept=menu_select.wav
name=OPTIONS name=OPTIONS
x=0 x=0

View File

@@ -1,13 +1,12 @@
font_png=smb2.png font_png=smb2.png
font_txt=smb2.txt font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav sound_move=menu_move.wav
sound_accept=menu_select.wav
name=PAUSE name=PAUSE
x=0 x=0
y=96 y=80
backgroundType=1 backgroundType=1
backgroundColor=41,57,65,240 backgroundColor=41,57,65,240
@@ -18,7 +17,13 @@ centerX=128
selector_color=255,122,0,255 selector_color=255,122,0,255
selector_text_color=255,255,255 selector_text_color=255,255,255
defaultActionWhenCancel=0 defaultActionWhenCancel=1
[item]
text=PAUSE MENU
hPaddingDown=7
selectable=false
[/item]
[item] [item]
text=CONTINUE text=CONTINUE

View File

@@ -0,0 +1,40 @@
font_png=smb2.png
font_txt=smb2.txt
sound_move=menu_move.wav
sound_accept=menu_select.wav
name=PLAYER_SELECT
x=0
y=116
backgroundType=0
backgroundColor=48,48,64,192
areElementsCenteredOnX=true
isCenteredOnX=true
centerX=128
selector_color=229,28,35,0
selector_text_color=255,180,0
defaultActionWhenCancel=3
[item]
text=SELECT PLAYER
hPaddingDown=7
selectable=false
[/item]
[item]
text=BAL1
hPaddingDown=2
[/item]
[item]
text=AROUNDER
hPaddingDown=7
[/item]
[item]
text=BACK
[/item]

View File

@@ -1,9 +1,8 @@
font_png=smb2.png font_png=smb2.png
font_txt=smb2.txt font_txt=smb2.txt
sound_cancel=menu_cancel.wav
sound_accept=menu_select.wav
sound_move=menu_move.wav sound_move=menu_move.wav
sound_accept=menu_select.wav
name=TITLE name=TITLE
x=0 x=0

Binary file not shown.

View File

@@ -8,11 +8,7 @@
Director::Director(std::string path) Director::Director(std::string path)
{ {
// Inicializa variables // Inicializa variables
section.name = PROG_SECTION_GAME; section.name = PROG_SECTION_LOGO;
section.subsection = GAME_SECTION_PLAY_1P;
section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1;
// 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("\\/")) + "/../");
@@ -186,7 +182,6 @@ bool Director::setFileList()
asset->add("data/sound/hiscore.wav", t_sound); asset->add("data/sound/hiscore.wav", t_sound);
asset->add("data/sound/itemdrop.wav", t_sound); asset->add("data/sound/itemdrop.wav", t_sound);
asset->add("data/sound/itempickup.wav", t_sound); asset->add("data/sound/itempickup.wav", t_sound);
asset->add("data/sound/menu_cancel.wav", t_sound);
asset->add("data/sound/menu_move.wav", t_sound); asset->add("data/sound/menu_move.wav", t_sound);
asset->add("data/sound/menu_select.wav", t_sound); asset->add("data/sound/menu_select.wav", t_sound);
asset->add("data/sound/player_collision.wav", t_sound); asset->add("data/sound/player_collision.wav", t_sound);
@@ -280,6 +275,7 @@ bool Director::setFileList()
asset->add("data/menu/options.men", t_data); asset->add("data/menu/options.men", t_data);
asset->add("data/menu/pause.men", t_data); asset->add("data/menu/pause.men", t_data);
asset->add("data/menu/gameover.men", t_data); asset->add("data/menu/gameover.men", t_data);
asset->add("data/menu/player_select.men", t_data);
return asset->check(); return asset->check();
} }
@@ -305,6 +301,7 @@ bool Director::loadConfigFile()
options->windowSize = 3; options->windowSize = 3;
options->language = ba_BA; options->language = ba_BA;
options->difficulty = DIFFICULTY_NORMAL; options->difficulty = DIFFICULTY_NORMAL;
options->playerSelected = 0;
options->filter = FILTER_NEAREST; options->filter = FILTER_NEAREST;
options->vSync = true; options->vSync = true;
options->screenWidth = GAME_WIDTH; options->screenWidth = GAME_WIDTH;

View File

@@ -199,14 +199,14 @@ void Game::init()
// Crea los jugadores // Crea los jugadores
if (numPlayers == 1) if (numPlayers == 1)
{ {
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, player1Textures, playerAnimations); Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(options->playerSelected), playerAnimations);
players.push_back(player); players.push_back(player);
} }
else if (numPlayers == 2) else if (numPlayers == 2)
{ {
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, player1Textures, playerAnimations); Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(0), playerAnimations);
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, player2Textures, playerAnimations); Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures.at(1), playerAnimations);
players.push_back(player1); players.push_back(player1);
players.push_back(player2); players.push_back(player2);
} }
@@ -447,6 +447,8 @@ void Game::loadMedia()
LTexture *player1Fire = new LTexture(renderer, asset->get("player_bal1_fire.png")); LTexture *player1Fire = new LTexture(renderer, asset->get("player_bal1_fire.png"));
player1Textures.push_back(player1Fire); player1Textures.push_back(player1Fire);
playerTextures.push_back(player1Textures);
// Texturas - Player2 // Texturas - Player2
LTexture *player2Head = new LTexture(renderer, asset->get("player_arounder_head.png")); LTexture *player2Head = new LTexture(renderer, asset->get("player_arounder_head.png"));
player2Textures.push_back(player2Head); player2Textures.push_back(player2Head);
@@ -463,6 +465,8 @@ void Game::loadMedia()
LTexture *player2Fire = new LTexture(renderer, asset->get("player_arounder_fire.png")); LTexture *player2Fire = new LTexture(renderer, asset->get("player_arounder_fire.png"));
player2Textures.push_back(player2Fire); player2Textures.push_back(player2Fire);
playerTextures.push_back(player2Textures);
// Animaciones -- Jugador // Animaciones -- Jugador
std::vector<std::string> *playerHeadAnimation = new std::vector<std::string>; std::vector<std::string> *playerHeadAnimation = new std::vector<std::string>;
loadAnimations(asset->get("player_head.ani"), playerHeadAnimation); loadAnimations(asset->get("player_head.ani"), playerHeadAnimation);
@@ -541,8 +545,9 @@ void Game::loadMedia()
gameOverMenu->setRectSize(w, 0); gameOverMenu->setRectSize(w, 0);
gameOverMenu->centerMenuOnX(199); gameOverMenu->centerMenuOnX(199);
pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men")); pauseMenu = new Menu(renderer, asset, input, asset->get("pause.men"));
pauseMenu->setItemCaption(0, lang->getText(46)); pauseMenu->setItemCaption(0, lang->getText(41));
pauseMenu->setItemCaption(1, lang->getText(47)); pauseMenu->setItemCaption(1, lang->getText(46));
pauseMenu->setItemCaption(2, lang->getText(47));
// Sonidos // Sonidos
balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str()); balloonSound = JA_LoadSound(asset->get("balloon.wav").c_str());
@@ -3272,13 +3277,8 @@ section_t Game::run()
return section; return section;
} }
// Bucle para el menu de pausa del juego // Actualiza las variables del menu de pausa del juego
void Game::runPausedGame() void Game::updatePausedGame()
{
// Reinicia el menu
pauseMenu->reset();
while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
{ {
// Comprueba los eventos que hay en la cola // Comprueba los eventos que hay en la cola
checkEventHandler(); checkEventHandler();
@@ -3289,18 +3289,48 @@ void Game::runPausedGame()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
// Actualiza la lógica del menu // Actualiza la lógica del menu de pausa
pauseMenu->update(); pauseMenu->update();
// Comprueba las entradas para el menu
pauseMenu->checkInput();
// Comprueba si se ha seleccionado algún item del menú
switch (pauseMenu->getItemSelected())
{
case 1:
section.name = PROG_SECTION_GAME;
section.subsection = numPlayers == 1 ? GAME_SECTION_PLAY_1P : GAME_SECTION_PLAY_2P;
if (JA_GetMusicState() == JA_MUSIC_PAUSED)
{
JA_ResumeMusic();
}
break;
case 2:
fade->setFadeType(FADE_CENTER);
fade->activateFade();
break;
default:
break;
}
// Actualiza el fade
fade->update(); fade->update();
if (fade->hasEnded()) if (fade->hasEnded())
{ {
section.name = PROG_SECTION_TITLE; section.name = PROG_SECTION_TITLE;
section.subsection = TITLE_SECTION_1; section.subsection = TITLE_SECTION_1;
JA_StopMusic(); JA_StopMusic();
break; }
} }
} }
// Dibuja el menu de pausa del juego
void Game::renderPausedGame()
{
// Prepara para empezar a dibujar en la textura de juego // Prepara para empezar a dibujar en la textura de juego
screen->start(); screen->start();
@@ -3336,39 +3366,18 @@ void Game::runPausedGame()
// Vuelca el contenido del renderizador en pantalla // Vuelca el contenido del renderizador en pantalla
screen->blit(); screen->blit();
// Comprueba las entradas para el menu
pauseMenu->checkInput();
// Comprueba si se ha seleccionado algún item del menú
switch (pauseMenu->getItemSelected())
{
case 0:
section.name = PROG_SECTION_GAME;
if (numPlayers == 1)
{
section.subsection = GAME_SECTION_PLAY_1P;
}
else
{
section.subsection = GAME_SECTION_PLAY_2P;
} }
if (JA_GetMusicState() == JA_MUSIC_PAUSED) // Bucle para el menu de pausa del juego
void Game::runPausedGame()
{ {
JA_ResumeMusic(); // Reinicia el menu
} pauseMenu->reset();
break;
case 1: while ((section.subsection == GAME_SECTION_PAUSE) && (section.name == PROG_SECTION_GAME))
fade->setFadeType(FADE_CENTER); {
fade->activateFade(); updatePausedGame();
break; renderPausedGame();
default:
break;
}
} }
} }

View File

@@ -132,6 +132,7 @@ private:
std::vector<LTexture *> balloonTextures; // Vector con las texturas de los globos std::vector<LTexture *> balloonTextures; // Vector con las texturas de los globos
std::vector<LTexture *> player1Textures; // Vector con las texturas del jugador std::vector<LTexture *> player1Textures; // Vector con las texturas del jugador
std::vector<LTexture *> player2Textures; // Vector con las texturas del jugador std::vector<LTexture *> player2Textures; // Vector con las texturas del jugador
std::vector<std::vector<LTexture *>> playerTextures; // Vector con todas las texturas de los jugadores;
LTexture *gameBuildingsTexture; // Textura con los edificios de fondo LTexture *gameBuildingsTexture; // Textura con los edificios de fondo
LTexture *gameCloudsTexture; // Textura con las nubes de fondo LTexture *gameCloudsTexture; // Textura con las nubes de fondo
@@ -464,6 +465,12 @@ private:
// Agita la pantalla // Agita la pantalla
void shakeScreen(); void shakeScreen();
// Actualiza las variables del menu de pausa del juego
void updatePausedGame();
// Dibuja el menu de pausa del juego
void renderPausedGame();
// Bucle para el menu de pausa del juego // Bucle para el menu de pausa del juego
void runPausedGame(); void runPausedGame();

View File

@@ -58,6 +58,9 @@ Menu::Menu(SDL_Renderer *renderer, Asset *asset, Input *input, std::string file)
{ {
load(file); load(file);
} }
// Deja el cursor en el primer elemento
reset();
} }
Menu::~Menu() Menu::~Menu()
@@ -492,6 +495,13 @@ void Menu::reset()
selector.originH = selector.targetH = item[0].rect.h; selector.originH = selector.targetH = item[0].rect.h;
selector.moving = false; selector.moving = false;
selector.resizing = false; selector.resizing = false;
// Si el primer elemento no es seleccionable, incrementa el selector
if (!item[selector.index].selectable)
{
increaseSelectorIndex();
setSelectorPos(selector.index);
}
} }
// Actualiza el menu para recolocarlo correctamente y establecer el tamaño // Actualiza el menu para recolocarlo correctamente y establecer el tamaño
@@ -833,9 +843,6 @@ void Menu::setItemCaption(int index, std::string text)
item.at(index).rect.w = this->text->lenght(item.at(index).label); item.at(index).rect.w = this->text->lenght(item.at(index).label);
item.at(index).rect.h = this->text->getCharacterSize(); item.at(index).rect.h = this->text->getCharacterSize();
reorganize(); reorganize();
const std::string t = item.at(index).label + ":" + std::to_string(item.at(index).rect.w);
printf("Adding menu item -> %s\n", t.c_str());
} }
// Establece el indice del itemm que se usará por defecto al cancelar el menu // Establece el indice del itemm que se usará por defecto al cancelar el menu

View File

@@ -13,7 +13,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
this->section = section; this->section = section;
// Reserva memoria para los punteros propios // Reserva memoria para los punteros
eventHandler = new SDL_Event(); eventHandler = new SDL_Event();
fade = new Fade(renderer); fade = new Fade(renderer);
@@ -33,6 +33,7 @@ Title::Title(SDL_Renderer *renderer, Screen *screen, Input *input, Asset *asset,
menu.title = new Menu(renderer, asset, input, asset->get("title.men")); menu.title = new Menu(renderer, asset, input, asset->get("title.men"));
menu.options = new Menu(renderer, asset, input, asset->get("options.men")); menu.options = new Menu(renderer, asset, input, asset->get("options.men"));
menu.playerSelect = new Menu(renderer, asset, input, asset->get("player_select.men"));
// Sonidos // Sonidos
crashSound = JA_LoadSound(asset->get("title.wav").c_str()); crashSound = JA_LoadSound(asset->get("title.wav").c_str());
@@ -73,6 +74,7 @@ Title::~Title()
delete menu.title; delete menu.title;
delete menu.options; delete menu.options;
delete menu.playerSelect;
JA_DeleteSound(crashSound); JA_DeleteSound(crashSound);
JA_DeleteMusic(titleMusic); JA_DeleteMusic(titleMusic);
@@ -319,14 +321,13 @@ void Title::update()
menu.active->update(); menu.active->update();
} }
// Comprueba si se ha seleccionado algún item del menú // Comprueba si se ha seleccionado algún item del menú de titulo
if (menu.active->getName() == "TITLE") if (menu.active->getName() == "TITLE")
{ {
switch (menu.active->getItemSelected()) switch (menu.active->getItemSelected())
{ {
case 0: // 1 PLAYER case 0: // 1 PLAYER -> Cambia al manu de selección de jugador
postFade = 0; menu.active = menu.playerSelect;
fade->activateFade();
break; break;
case 1: // 2 PLAYERS case 1: // 2 PLAYERS
@@ -349,6 +350,37 @@ void Title::update()
} }
} }
// Comprueba si se ha seleccionado algún item del menú de selección de jugador
if (menu.active->getName() == "PLAYER_SELECT")
{
switch (menu.active->getItemSelected())
{
case 0:
// Este item no se puede seleccionar y actua de titulo
break;
case 1: // BAL1
postFade = 0;
options->playerSelected = 0;
fade->activateFade();
break;
case 2: // AROUNDER
postFade = 0;
options->playerSelected = 1;
fade->activateFade();
break;
case 3: // BACK
menu.active = menu.title;
menu.playerSelect->reset();
break;
default:
break;
}
}
// Comprueba si se ha seleccionado algún item de opciones // Comprueba si se ha seleccionado algún item de opciones
if (menu.active->getName() == "OPTIONS") if (menu.active->getName() == "OPTIONS")
{ {
@@ -873,6 +905,14 @@ void Title::updateMenuLabels()
// Recoloca el menu de titulo // Recoloca el menu de titulo
menu.title->centerMenuOnX(SCREEN_CENTER_X); menu.title->centerMenuOnX(SCREEN_CENTER_X);
menu.title->centerMenuElementsOnX(); menu.title->centerMenuElementsOnX();
// Establece las etiquetas del menu de seleccion de jugador
menu.playerSelect->setItemCaption(0, lang->getText(39)); // SELECT PLAYER
menu.playerSelect->setItemCaption(3, lang->getText(40)); // BACK
// Recoloca el menu de selección de jugador
menu.playerSelect->centerMenuOnX(SCREEN_CENTER_X);
menu.playerSelect->centerMenuElementsOnX();
} }
// Aplica las opciones de menu seleccionadas // Aplica las opciones de menu seleccionadas

View File

@@ -37,6 +37,7 @@ private:
{ {
Menu *title; // Menu de la pantalla de título Menu *title; // Menu de la pantalla de título
Menu *options; // Menú de la pantalla de opciones Menu *options; // Menú de la pantalla de opciones
Menu *playerSelect; // Menu para elegir jugador
Menu *active; // Menu activo (de momento para la pantalla del titulo) Menu *active; // Menu activo (de momento para la pantalla del titulo)
bool keyPressed; // Variable para evitar la repetición de teclas en los menus bool keyPressed; // Variable para evitar la repetición de teclas en los menus
}; };

View File

@@ -87,6 +87,7 @@ struct input_t
struct options_t struct options_t
{ {
Uint8 difficulty; // Dificultad del juego Uint8 difficulty; // Dificultad del juego
Uint8 playerSelected; // Jugador seleccionado para el modo 1P
std::vector<input_t> input; // Modo de control (teclado o mando) std::vector<input_t> input; // Modo de control (teclado o mando)
Uint8 language; // Idioma usado en el juego Uint8 language; // Idioma usado en el juego
Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa Uint32 fullScreenMode; // Contiene el valor del modo de pantalla completa