Compare commits
3 Commits
f8b6d0524d
...
7e60a742ca
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e60a742ca | |||
| 5c7bb842ec | |||
| 6a9d0d1b2c |
@@ -108,10 +108,12 @@ void Game::init(int playerID)
|
|||||||
// Crea los dos jugadores
|
// Crea los dos jugadores
|
||||||
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[0], playerAnimations);
|
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[0], playerAnimations);
|
||||||
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
player1->setScoreBoardPanel(SCOREBOARD_LEFT_PANEL);
|
||||||
|
player1->setName(lang->getText(53));
|
||||||
players.push_back(player1);
|
players.push_back(player1);
|
||||||
|
|
||||||
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[1], playerAnimations);
|
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 30, playerTextures[1], playerAnimations);
|
||||||
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
player2->setScoreBoardPanel(SCOREBOARD_RIGHT_PANEL);
|
||||||
|
player2->setName(lang->getText(54));
|
||||||
players.push_back(player2);
|
players.push_back(player2);
|
||||||
|
|
||||||
// Cambia el estado del jugador seleccionado
|
// Cambia el estado del jugador seleccionado
|
||||||
@@ -150,13 +152,13 @@ void Game::init(int playerID)
|
|||||||
|
|
||||||
// Variables para el marcador
|
// Variables para el marcador
|
||||||
scoreboard->setPos({param->scoreboard.x, param->scoreboard.y, param->scoreboard.w, param->scoreboard.h});
|
scoreboard->setPos({param->scoreboard.x, param->scoreboard.y, param->scoreboard.w, param->scoreboard.h});
|
||||||
if (players[0]->isWaiting())
|
for (auto player : players)
|
||||||
{
|
{
|
||||||
scoreboard->setMode(SCOREBOARD_LEFT_PANEL, SCOREBOARD_MODE_GAME_OVER);
|
scoreboard->setName(player->getScoreBoardPanel(), player->getName());
|
||||||
}
|
if (player->isWaiting())
|
||||||
if (!players[1]->isWaiting())
|
{
|
||||||
{
|
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_GAME_OVER);
|
||||||
scoreboard->setMode(SCOREBOARD_RIGHT_PANEL, SCOREBOARD_MODE_GAME_OVER);
|
}
|
||||||
}
|
}
|
||||||
scoreboard->setMode(SCOREBOARD_CENTER_PANEL, SCOREBOARD_MODE_STAGE_INFO);
|
scoreboard->setMode(SCOREBOARD_CENTER_PANEL, SCOREBOARD_MODE_STAGE_INFO);
|
||||||
|
|
||||||
@@ -2346,10 +2348,20 @@ void Game::checkInput()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Si no está jugando, el botón de start le permite continuar jugando
|
||||||
if (input->checkInput(input_start, ALLOW_REPEAT, options->controller[i].deviceType, options->controller[i].index))
|
if (input->checkInput(input_start, ALLOW_REPEAT, options->controller[i].deviceType, options->controller[i].index))
|
||||||
{
|
{
|
||||||
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
player->setStatusPlaying(PLAYER_STATUS_PLAYING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si está continuando, los botones de fuego hacen decrementar el contador
|
||||||
|
const bool fire1 = input->checkInput(input_fire_left, false, options->controller[i].deviceType, options->controller[i].index);
|
||||||
|
const bool fire2 = input->checkInput(input_fire_center, false, options->controller[i].deviceType, options->controller[i].index);
|
||||||
|
const bool fire3 = input->checkInput(input_fire_right, false, options->controller[i].deviceType, options->controller[i].index);
|
||||||
|
if (fire1 || fire2 || fire3)
|
||||||
|
{
|
||||||
|
player->decContinueCounter();
|
||||||
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2807,13 +2819,11 @@ void Game::setHiScore()
|
|||||||
// Actualiza el marcador
|
// Actualiza el marcador
|
||||||
void Game::updateScoreboard()
|
void Game::updateScoreboard()
|
||||||
{
|
{
|
||||||
// Jugador 1
|
for (auto player : players)
|
||||||
scoreboard->setScore1(players[0]->getScore());
|
{
|
||||||
scoreboard->setMult1(players[0]->getScoreMultiplier());
|
scoreboard->setScore(player->getScoreBoardPanel(), player->getScore());
|
||||||
|
scoreboard->setMult(player->getScoreBoardPanel(), player->getScoreMultiplier());
|
||||||
// Jugador 2
|
}
|
||||||
scoreboard->setScore2(players[1]->getScore());
|
|
||||||
scoreboard->setMult2(players[1]->getScoreMultiplier());
|
|
||||||
|
|
||||||
// Resto de marcador
|
// Resto de marcador
|
||||||
scoreboard->setStage(enemyFormations->getStage(currentStage).number);
|
scoreboard->setStage(enemyFormations->getStage(currentStage).number);
|
||||||
@@ -2854,7 +2864,7 @@ void Game::checkPlayersStatus()
|
|||||||
|
|
||||||
case PLAYER_STATUS_CONTINUE:
|
case PLAYER_STATUS_CONTINUE:
|
||||||
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_CONTINUE);
|
scoreboard->setMode(player->getScoreBoardPanel(), SCOREBOARD_MODE_CONTINUE);
|
||||||
scoreboard->setContinue1(player->getContinueCounter());
|
scoreboard->setContinue(player->getScoreBoardPanel(), player->getContinueCounter());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PLAYER_STATUS_WAITING:
|
case PLAYER_STATUS_WAITING:
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ Player::Player(float x, int y, std::vector<Texture *> texture, std::vector<std::
|
|||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
// enabled = false;
|
// enabled = false;
|
||||||
statusPlaying = PLAYER_STATUS_WAITING;
|
statusPlaying = PLAYER_STATUS_WAITING;
|
||||||
|
scoreBoardPanel = 0;
|
||||||
|
name = "";
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -542,16 +544,7 @@ void Player::updateContinueCounter()
|
|||||||
|
|
||||||
if (SDL_GetTicks() - continueTicks > ticksSpeed)
|
if (SDL_GetTicks() - continueTicks > ticksSpeed)
|
||||||
{
|
{
|
||||||
// Actualiza el contador de ticks
|
decContinueCounter();
|
||||||
continueTicks = SDL_GetTicks();
|
|
||||||
|
|
||||||
// Decrementa el contador
|
|
||||||
continueCounter--;
|
|
||||||
|
|
||||||
if (continueCounter < 0)
|
|
||||||
{
|
|
||||||
setStatusPlaying(PLAYER_STATUS_WAITING);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -567,3 +560,27 @@ int Player::getScoreBoardPanel()
|
|||||||
{
|
{
|
||||||
return scoreBoardPanel;
|
return scoreBoardPanel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decrementa el contador de continuar
|
||||||
|
void Player::decContinueCounter()
|
||||||
|
{
|
||||||
|
continueTicks = SDL_GetTicks();
|
||||||
|
continueCounter--;
|
||||||
|
|
||||||
|
if (continueCounter < 0)
|
||||||
|
{
|
||||||
|
setStatusPlaying(PLAYER_STATUS_WAITING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Establece el nombre del jugador
|
||||||
|
void Player::setName(std::string name)
|
||||||
|
{
|
||||||
|
this->name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtiene el nombre del jugador
|
||||||
|
std::string Player::getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
@@ -68,6 +68,7 @@ private:
|
|||||||
int continueCounter; // Contador para poder continuar
|
int continueCounter; // Contador para poder continuar
|
||||||
Uint32 continueTicks; // Variable para poder cambiar el contador de continue en función del tiempo
|
Uint32 continueTicks; // Variable para poder cambiar el contador de continue en función del tiempo
|
||||||
int scoreBoardPanel; // Panel del marcador asociado al jugador
|
int scoreBoardPanel; // Panel del marcador asociado al jugador
|
||||||
|
std::string name; // Nombre del jugador
|
||||||
|
|
||||||
// Actualiza el circulo de colisión a la posición del jugador
|
// Actualiza el circulo de colisión a la posición del jugador
|
||||||
void shiftColliders();
|
void shiftColliders();
|
||||||
@@ -225,4 +226,13 @@ public:
|
|||||||
|
|
||||||
// Obtiene el valor de la variable
|
// Obtiene el valor de la variable
|
||||||
int getScoreBoardPanel();
|
int getScoreBoardPanel();
|
||||||
|
|
||||||
|
// Decrementa el contador de continuar
|
||||||
|
void decContinueCounter();
|
||||||
|
|
||||||
|
// Establece el nombre del jugador
|
||||||
|
void setName(std::string name);
|
||||||
|
|
||||||
|
// Obtiene el nombre del jugador
|
||||||
|
std::string getName();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ Scoreboard::Scoreboard(SDL_Renderer *renderer, Screen *screen, Asset *asset, Lan
|
|||||||
|
|
||||||
// Inicializa variables
|
// Inicializa variables
|
||||||
stage = 1;
|
stage = 1;
|
||||||
score1 = 0;
|
for (int i = 0; i< SCOREBOARD_MAX_PANELS; ++i)
|
||||||
score2 = 0;
|
{
|
||||||
mult1 = 1;
|
name[i] = "";
|
||||||
mult2 = 1;
|
score[i] = 0;
|
||||||
continue1 = 0;
|
mult[i] = 0;
|
||||||
continue2 = 0;
|
continueCounter[i] = 0;
|
||||||
|
}
|
||||||
hiScore = 0;
|
hiScore = 0;
|
||||||
power = 0;
|
power = 0;
|
||||||
hiScoreName = "";
|
hiScoreName = "";
|
||||||
@@ -138,39 +139,27 @@ void Scoreboard::render()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Scoreboard::setScore1(int score)
|
void Scoreboard::setName(int panel, std::string name)
|
||||||
{
|
{
|
||||||
score1 = score;
|
this->name[panel] = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Scoreboard::setScore2(int score)
|
void Scoreboard::setScore(int panel, int score)
|
||||||
{
|
{
|
||||||
score2 = score;
|
this->score[panel] = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Scoreboard::setMult1(float mult)
|
void Scoreboard::setMult(int panel, float mult)
|
||||||
{
|
{
|
||||||
mult1 = mult;
|
this->mult[panel] = mult;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void Scoreboard::setMult2(float mult)
|
void Scoreboard::setContinue(int panel, int value)
|
||||||
{
|
{
|
||||||
mult2 = mult;
|
continueCounter[panel] = value;
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Scoreboard::setContinue1(int value)
|
|
||||||
{
|
|
||||||
continue1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void Scoreboard::setContinue2(int value)
|
|
||||||
{
|
|
||||||
continue2 = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
@@ -242,12 +231,12 @@ void Scoreboard::fillPanelTextures()
|
|||||||
{
|
{
|
||||||
case SCOREBOARD_MODE_SCORE:
|
case SCOREBOARD_MODE_SCORE:
|
||||||
// SCORE
|
// SCORE
|
||||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, lang->getText(53));
|
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]);
|
||||||
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score1));
|
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score[i]));
|
||||||
|
|
||||||
// MULT
|
// MULT
|
||||||
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang->getText(55));
|
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, lang->getText(55));
|
||||||
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, std::to_string(mult1).substr(0, 3));
|
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, std::to_string(mult[i]).substr(0, 3));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCOREBOARD_MODE_DEMO:
|
case SCOREBOARD_MODE_DEMO:
|
||||||
@@ -285,12 +274,12 @@ void Scoreboard::fillPanelTextures()
|
|||||||
|
|
||||||
case SCOREBOARD_MODE_CONTINUE:
|
case SCOREBOARD_MODE_CONTINUE:
|
||||||
// SCORE
|
// SCORE
|
||||||
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, lang->getText(53));
|
textScoreBoard->writeCentered(slot4_1.x, slot4_1.y, name[i]);
|
||||||
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score1));
|
textScoreBoard->writeCentered(slot4_2.x, slot4_2.y, updateScoreText(score[i]));
|
||||||
|
|
||||||
// CONTINUE
|
// CONTINUE
|
||||||
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, "Continuar?");
|
textScoreBoard->writeCentered(slot4_3.x, slot4_3.y, "Continuar?");
|
||||||
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, std::to_string(continue1));
|
textScoreBoard->writeCentered(slot4_4.x, slot4_4.y, std::to_string(continueCounter[i]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -10,11 +10,10 @@
|
|||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
|
|
||||||
// Defines
|
// Defines
|
||||||
#define SCOREBOARD_MAX_PANELS 3
|
|
||||||
|
|
||||||
#define SCOREBOARD_LEFT_PANEL 0
|
#define SCOREBOARD_LEFT_PANEL 0
|
||||||
#define SCOREBOARD_CENTER_PANEL 1
|
#define SCOREBOARD_CENTER_PANEL 1
|
||||||
#define SCOREBOARD_RIGHT_PANEL 2
|
#define SCOREBOARD_RIGHT_PANEL 2
|
||||||
|
#define SCOREBOARD_MAX_PANELS 3
|
||||||
|
|
||||||
#define SCOREBOARD_TICK_SPEED 100
|
#define SCOREBOARD_TICK_SPEED 100
|
||||||
|
|
||||||
@@ -52,22 +51,20 @@ private:
|
|||||||
std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel;
|
std::vector<SDL_Texture *> panelTexture; // Texturas para dibujar cada panel;
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
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
|
||||||
int stage; // Número de fase actual
|
int stage; // Número de fase actual
|
||||||
int score1; // Puntuación del jugador 1
|
std::string name[SCOREBOARD_MAX_PANELS]; // Nom de cada jugador
|
||||||
int score2; // Puntuación del jugador 2
|
int score[SCOREBOARD_MAX_PANELS]; // Puntuación de los jugadores
|
||||||
float mult1; // Multiplicador del jugador 1
|
float mult[SCOREBOARD_MAX_PANELS]; // Multiplicador de los jugadores
|
||||||
float mult2; // Multiplicador del jugador 2
|
int continueCounter[SCOREBOARD_MAX_PANELS]; // Tiempo para continuar de los jugadores
|
||||||
int continue1; // Tiempo para continuar del jugador 1
|
int hiScore; // Máxima puntuación
|
||||||
int continue2; // Tiempo para continuar del jugador 2
|
float power; // Poder actual de la fase
|
||||||
int hiScore; // Máxima puntuación
|
std::string hiScoreName; // Nombre del jugador con la máxima puntuación
|
||||||
float power; // Poder actual de la fase
|
color_t color; // Color del marcador
|
||||||
std::string hiScoreName; // Nombre del jugador con la máxima puntuación
|
SDL_Rect rect; // Posición y dimensiones del marcador
|
||||||
color_t color; // Color del marcador
|
panel_t panel[SCOREBOARD_MAX_PANELS]; // Lista con todos los paneles del marcador
|
||||||
SDL_Rect rect; // Posición y dimensiones del marcador
|
Uint32 ticks; // Variable donde almacenar el valor de SDL_GetTiks()
|
||||||
panel_t panel[SCOREBOARD_MAX_PANELS]; // Lista con todos los paneles del marcador
|
int counter; // Contador
|
||||||
Uint32 ticks; // Variable donde almacenar el valor de SDL_GetTiks()
|
|
||||||
int counter; // Contador
|
|
||||||
|
|
||||||
// Puntos predefinidos para colocar elementos en los paneles
|
// Puntos predefinidos para colocar elementos en los paneles
|
||||||
SDL_Point slot4_1, slot4_2, slot4_3, slot4_4;
|
SDL_Point slot4_1, slot4_2, slot4_3, slot4_4;
|
||||||
@@ -108,22 +105,16 @@ public:
|
|||||||
void render();
|
void render();
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setScore1(int score);
|
void setName(int panel, std::string name);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setScore2(int score);
|
void setScore(int panel, int score);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setMult1(float mult);
|
void setMult(int panel, float mult);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setMult2(float mult);
|
void setContinue(int panel, int score);
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setContinue1(int score);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
|
||||||
void setContinue2(int score);
|
|
||||||
|
|
||||||
// Establece el valor de la variable
|
// Establece el valor de la variable
|
||||||
void setStage(int stage);
|
void setStage(int stage);
|
||||||
|
|||||||
Reference in New Issue
Block a user