Compare commits

...

3 Commits

5 changed files with 45 additions and 84 deletions

View File

@@ -41,10 +41,10 @@ MASK_TYPE defines what, if any, shadow mask to use. MASK_BRIGHTNESS defines how
#define MULTISAMPLE #define MULTISAMPLE
#define GAMMA #define GAMMA
//#define FAKE_GAMMA //#define FAKE_GAMMA
#define CURVATURE //#define CURVATURE
//#define SHARPER //#define SHARPER
// MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish) // MASK_TYPE: 0 = none, 1 = green/magenta, 2 = trinitron(ish)
#define MASK_TYPE 1 #define MASK_TYPE 2
#ifdef GL_ES #ifdef GL_ES
@@ -64,12 +64,12 @@ uniform COMPAT_PRECISION float BLOOM_FACTOR;
uniform COMPAT_PRECISION float INPUT_GAMMA; uniform COMPAT_PRECISION float INPUT_GAMMA;
uniform COMPAT_PRECISION float OUTPUT_GAMMA; uniform COMPAT_PRECISION float OUTPUT_GAMMA;
#else #else
#define CURVATURE_X 0.25 #define CURVATURE_X 0.05
#define CURVATURE_Y 0.45 #define CURVATURE_Y 0.1
#define MASK_BRIGHTNESS 0.70 #define MASK_BRIGHTNESS 0.80
#define SCANLINE_WEIGHT 6.0 #define SCANLINE_WEIGHT 6.0
#define SCANLINE_GAP_BRIGHTNESS 0.12 #define SCANLINE_GAP_BRIGHTNESS 0.12
#define BLOOM_FACTOR 1.5 #define BLOOM_FACTOR 3.5
#define INPUT_GAMMA 2.4 #define INPUT_GAMMA 2.4
#define OUTPUT_GAMMA 2.2 #define OUTPUT_GAMMA 2.2
#endif #endif

View File

@@ -1,7 +1,9 @@
#include "game.h" #include "game.h"
#define DEATH_COUNTER 350
// Constructor // Constructor
Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section) Game::Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section)
{ {
// Copia los punteros // Copia los punteros
this->renderer = renderer; this->renderer = renderer;
@@ -18,11 +20,6 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
this->numPlayers = numPlayers; this->numPlayers = numPlayers;
this->currentStage = currentStage; this->currentStage = currentStage;
lastStageReached = currentStage; lastStageReached = currentStage;
if (numPlayers == 1)
{ // Si solo juega un jugador, permite jugar tanto con teclado como con mando
onePlayerControl = options->game.input[0].deviceType;
options->game.input[0].deviceType = INPUT_USE_ANY;
}
difficulty = options->game.difficulty; difficulty = options->game.difficulty;
// Crea los objetos // Crea los objetos
@@ -51,7 +48,7 @@ Game::Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *scr
SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND); SDL_SetTextureBlendMode(canvas, SDL_BLENDMODE_BLEND);
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
init(); init(playerID);
} }
Game::~Game() Game::~Game()
@@ -59,12 +56,6 @@ Game::~Game()
saveScoreFile(); saveScoreFile();
saveDemoFile(); saveDemoFile();
// Restaura el metodo de control
if (numPlayers == 1)
{
options->game.input[0].deviceType = onePlayerControl;
}
// Elimina todos los objetos contenidos en vectores // Elimina todos los objetos contenidos en vectores
deleteAllVectorObjects(); deleteAllVectorObjects();
@@ -165,7 +156,7 @@ Game::~Game()
} }
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
void Game::init() void Game::init(int playerID)
{ {
ticks = 0; ticks = 0;
ticksSpeed = 15; ticksSpeed = 15;
@@ -178,19 +169,14 @@ void Game::init()
players.clear(); players.clear();
// Crea los jugadores // Crea los jugadores
if (numPlayers == 1) Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[0], playerAnimations);
{ players.push_back(player1);
Player *player = new Player(PLAY_AREA_CENTER_X - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[options->game.playerSelected], playerAnimations);
players.push_back(player); Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[1], playerAnimations);
} players.push_back(player2);
else if (numPlayers == 2)
{
Player *player1 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((0 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[0], playerAnimations);
Player *player2 = new Player((PLAY_AREA_CENTER_FIRST_QUARTER_X * ((1 * 2) + 1)) - 11, PLAY_AREA_BOTTOM - 24, renderer, playerTextures[1], playerAnimations);
players.push_back(player1);
players.push_back(player2);
}
// Variables relacionadas con la dificultad // Variables relacionadas con la dificultad
switch (difficulty) switch (difficulty)
@@ -2931,6 +2917,10 @@ void Game::checkGameInput()
} }
else else
{ {
if (input->checkInput(input_accept, REPEAT_TRUE, options->game.input[i].deviceType, options->game.input[i].id))
{
player->init();
}
i++; i++;
} }
} }
@@ -3348,6 +3338,8 @@ void Game::updateScoreboard()
{ {
scoreboard->setScore1(players[0]->getScore()); scoreboard->setScore1(players[0]->getScore());
scoreboard->setMult1(players[0]->getScoreMultiplier()); scoreboard->setMult1(players[0]->getScoreMultiplier());
scoreboard->setScore2(players[0]->getScore());
scoreboard->setMult2(players[0]->getScoreMultiplier());
scoreboard->setStage(stage[currentStage].number); scoreboard->setStage(stage[currentStage].number);
scoreboard->setPower((float)stage[currentStage].currentPower / (float)stage[currentStage].powerToComplete); scoreboard->setPower((float)stage[currentStage].currentPower / (float)stage[currentStage].powerToComplete);
scoreboard->setHiScore(hiScore); scoreboard->setHiScore(hiScore);

View File

@@ -208,7 +208,6 @@ private:
color_t difficultyColor; // Color asociado a la dificultad color_t difficultyColor; // Color asociado a la dificultad
options_t *options; // Variable con todas las opciones del programa options_t *options; // Variable con todas las opciones del programa
param_t *param; // Puntero con todos los parametros del programa param_t *param; // Puntero con todos los parametros 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 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
@@ -226,7 +225,7 @@ private:
void checkEvents(); void checkEvents();
// Inicializa las variables necesarias para la sección 'Game' // Inicializa las variables necesarias para la sección 'Game'
void init(); void init(int playerID);
// Carga los recursos necesarios para la sección 'Game' // Carga los recursos necesarios para la sección 'Game'
void loadMedia(); void loadMedia();
@@ -473,7 +472,7 @@ private:
public: public:
// Constructor // Constructor
Game(int numPlayers, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section); Game(int playerID, int currentStage, SDL_Renderer *renderer, Screen *screen, Asset *asset, Lang *lang, Input *input, bool demo, param_t *param, options_t *options, section_t *section);
// Destructor // Destructor
~Game(); ~Game();

View File

@@ -16,8 +16,8 @@ Player::Player(float x, int y, SDL_Renderer *renderer, std::vector<Texture *> te
fireSprite->getTexture()->setAlpha(224); fireSprite->getTexture()->setAlpha(224);
// Establece la posición inicial del jugador // Establece la posición inicial del jugador
posX = x; defaultPosX = posX = x;
posY = y; defaultPosY = posY = y;
init(); init();
} }
@@ -36,11 +36,12 @@ Player::~Player()
void Player::init() void Player::init()
{ {
// Inicializa variables de estado // Inicializa variables de estado
posX = defaultPosX;
posY = defaultPosY;
alive = true; alive = true;
deathCounter = DEATH_COUNTER;
statusWalking = PLAYER_STATUS_WALKING_STOP; statusWalking = PLAYER_STATUS_WALKING_STOP;
statusFiring = PLAYER_STATUS_FIRING_NO; statusFiring = PLAYER_STATUS_FIRING_NO;
invulnerable = false; invulnerable = true;
invulnerableCounter = PLAYER_INVULNERABLE_COUNTER; invulnerableCounter = PLAYER_INVULNERABLE_COUNTER;
powerUp = false; powerUp = false;
powerUpCounter = PLAYER_POWERUP_COUNTER; powerUpCounter = PLAYER_POWERUP_COUNTER;
@@ -134,7 +135,8 @@ void Player::move()
// Si el jugador abandona el area de juego por los laterales // Si el jugador abandona el area de juego por los laterales
if ((posX < PLAY_AREA_LEFT - 5) || (posX + width > PLAY_AREA_RIGHT + 5)) if ((posX < PLAY_AREA_LEFT - 5) || (posX + width > PLAY_AREA_RIGHT + 5))
{ // Restaura su posición {
// Restaura su posición
posX -= velX; posX -= velX;
} }
@@ -157,7 +159,8 @@ void Player::move()
// Si el cadaver abandona el area de juego por los laterales // Si el cadaver abandona el area de juego por los laterales
if ((deathSprite->getPosX() < PLAY_AREA_LEFT) || (deathSprite->getPosX() + width > PLAY_AREA_RIGHT)) if ((deathSprite->getPosX() < PLAY_AREA_LEFT) || (deathSprite->getPosX() + width > PLAY_AREA_RIGHT))
{ // Restaura su posición {
// Restaura su posición
const float vx = deathSprite->getVelX(); const float vx = deathSprite->getVelX();
deathSprite->setPosX(deathSprite->getPosX() - vx); deathSprite->setPosX(deathSprite->getPosX() - vx);
@@ -209,7 +212,6 @@ void Player::setWalkingStatus(Uint8 status)
if (statusWalking != status) if (statusWalking != status)
{ {
statusWalking = status; statusWalking = status;
// legsSprite->setCurrentFrame(0);
} }
} }
@@ -246,14 +248,16 @@ void Player::setAnimation()
legsSprite->setCurrentAnimation(aWalking); legsSprite->setCurrentAnimation(aWalking);
legsSprite->setFlip(flipWalk); legsSprite->setFlip(flipWalk);
if (statusFiring == PLAYER_STATUS_FIRING_NO) if (statusFiring == PLAYER_STATUS_FIRING_NO)
{ // No esta disparando {
// No esta disparando
bodySprite->setCurrentAnimation(aWalking + aBodyCoffees + aPowerUp); bodySprite->setCurrentAnimation(aWalking + aBodyCoffees + aPowerUp);
bodySprite->setFlip(flipWalk); bodySprite->setFlip(flipWalk);
headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp); headSprite->setCurrentAnimation(aWalking + aHeadCoffees + aPowerUp);
headSprite->setFlip(flipWalk); headSprite->setFlip(flipWalk);
} }
else else
{ // Está disparando {
// Está disparando
bodySprite->setCurrentAnimation(aFiring + aBodyCoffees + aPowerUp); bodySprite->setCurrentAnimation(aFiring + aBodyCoffees + aPowerUp);
bodySprite->setFlip(flipFire); bodySprite->setFlip(flipFire);
headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp); headSprite->setCurrentAnimation(aFiring + aHeadCoffees + aPowerUp);
@@ -297,14 +301,7 @@ int Player::getHeight()
bool Player::canFire() bool Player::canFire()
{ {
// Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador // Si el contador a llegado a cero, podemos disparar. En caso contrario decrementamos el contador
if (cooldown > 0) return cooldown > 0 ? false : true;
{
return false;
}
else
{
return true;
}
} }
// Establece el valor de la variable // Establece el valor de la variable
@@ -339,7 +336,6 @@ void Player::update()
updateCooldown(); updateCooldown();
updatePowerUpCounter(); updatePowerUpCounter();
updateInvulnerableCounter(); updateInvulnerableCounter();
updateDeathCounter();
updatePowerUpHeadOffset(); updatePowerUpHeadOffset();
} }
@@ -465,18 +461,6 @@ void Player::updateInvulnerableCounter()
} }
} }
// Actualiza el valor de la variable
void Player::updateDeathCounter()
{
if (!alive)
{
if (deathCounter > 0)
{
deathCounter--;
}
}
}
// Obtiene el valor de la variable // Obtiene el valor de la variable
bool Player::isPowerUp() bool Player::isPowerUp()
{ {
@@ -582,13 +566,6 @@ void Player::shiftColliders()
Texture *Player::getDeadTexture() Texture *Player::getDeadTexture()
{ {
return deathSprite->getTexture(); return deathSprite->getTexture();
;
}
// Obtiene el valor de la variable
Uint16 Player::getDeathCounter()
{
return deathCounter;
} }
// Actualiza el valor de la variable // Actualiza el valor de la variable

View File

@@ -10,9 +10,6 @@
#ifndef PLAYER_H #ifndef PLAYER_H
#define PLAYER_H #define PLAYER_H
// Contadores
#define DEATH_COUNTER 350
// Estados del jugador // Estados del jugador
#define PLAYER_STATUS_WALKING_LEFT 0 #define PLAYER_STATUS_WALKING_LEFT 0
#define PLAYER_STATUS_WALKING_RIGHT 1 #define PLAYER_STATUS_WALKING_RIGHT 1
@@ -37,12 +34,15 @@ private:
AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo AnimatedSprite *bodySprite; // Sprite para dibujar el cuerpo
AnimatedSprite *legsSprite; // Sprite para dibujar las piernas AnimatedSprite *legsSprite; // Sprite para dibujar las piernas
AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado AnimatedSprite *deathSprite; // Sprite para dibujar el jugador derrotado
AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope AnimatedSprite *fireSprite; // Sprite para dibujar el aura del jugador con el poder a tope
// Variables // Variables
float posX; // Posicion en el eje X float posX; // Posicion en el eje X
int posY; // Posicion en el eje Y int posY; // Posicion en el eje Y
float defaultPosX; // Posición inicial para el jugador
int defaultPosY; // Posición inicial para el jugador
Uint8 width; // Anchura Uint8 width; // Anchura
Uint8 height; // Altura Uint8 height; // Altura
@@ -58,8 +58,6 @@ private:
Uint8 statusWalking; // Estado del jugador Uint8 statusWalking; // Estado del jugador
Uint8 statusFiring; // Estado del jugador Uint8 statusFiring; // Estado del jugador
bool alive; // Indica si el jugador está vivo
Uint16 deathCounter; // Contador para la animación de morirse
bool invulnerable; // Indica si el jugador es invulnerable bool invulnerable; // Indica si el jugador es invulnerable
Uint16 invulnerableCounter; // Contador para la invulnerabilidad Uint16 invulnerableCounter; // Contador para la invulnerabilidad
bool extraHit; // Indica si el jugador tiene un toque extra bool extraHit; // Indica si el jugador tiene un toque extra
@@ -68,6 +66,7 @@ private:
Uint16 powerUpCounter; // Temporizador para el modo PowerUp Uint16 powerUpCounter; // Temporizador para el modo PowerUp
bool input; // Indica si puede recibir ordenes de entrada bool input; // Indica si puede recibir ordenes de entrada
circle_t collider; // Circulo de colisión del jugador circle_t collider; // Circulo de colisión del jugador
bool alive; // Indica si el jugador está vivo
// 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();
@@ -75,9 +74,6 @@ private:
// Actualiza el valor de la variable // Actualiza el valor de la variable
void updateInvulnerableCounter(); void updateInvulnerableCounter();
// Actualiza el valor de la variable
void updateDeathCounter();
// Actualiza el valor de la variable // Actualiza el valor de la variable
void updatePowerUpHeadOffset(); void updatePowerUpHeadOffset();
@@ -213,9 +209,6 @@ public:
// Obtiene el puntero a la textura con los gráficos de la animación de morir // Obtiene el puntero a la textura con los gráficos de la animación de morir
Texture *getDeadTexture(); Texture *getDeadTexture();
// Obtiene el valor de la variable
Uint16 getDeathCounter();
}; };
#endif #endif