Compare commits

...

2 Commits

Author SHA1 Message Date
eb9eaec61d arreglos en la powerball:
- quan apareix al centro, pot anar cap a l'esquerra o cap a la dreta
 - ara apareix a la altura que li toca als globos grans
 - tarda en generarse igual que la resta de globos
 - rebota igual que els globos grans (com feia abans de canviar les físiques dels globos grans)
2024-08-13 11:29:13 +02:00
8c7ff13bc2 modificat Makefile 2024-08-13 07:27:18 +02:00
3 changed files with 60 additions and 29 deletions

View File

@@ -121,7 +121,7 @@ print-variables:
@echo RM: $(RM) @echo RM: $(RM)
raspi3: raspi3:
$(CXX) $(SOURCES) -D NO_SHADERS $(CXXFLAGS) -lSDL2 -o $(TARGET_FILE) $(CXX) $(SOURCES) -D NO_SHADERS -D VERBOSE $(CXXFLAGS) -lSDL2 -o $(TARGET_FILE)
strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded strip -s -R .comment -R .gnu.version $(TARGET_FILE) --strip-unneeded
raspi5: raspi5:

View File

@@ -199,8 +199,8 @@ Balloon::Balloon(float x, float y, Uint8 kind, float velx, float speed, Uint16 c
this->velX = velx; this->velX = velx;
velY = 0; velY = 0;
maxVelY = 3.0f; maxVelY = 3.0f;
gravity = 0.10f; gravity = param->balloon4.grav;
defaultVelY = 4.95f; defaultVelY = param->balloon4.vel;
// Puntos que da el globo al ser destruido // Puntos que da el globo al ser destruido
score = 0; score = 0;

View File

@@ -882,7 +882,9 @@ void Game::deployEnemyFormation()
// Evita repetir la ultima formación enemiga desplegada // Evita repetir la ultima formación enemiga desplegada
if (set == lastEnemyDeploy) if (set == lastEnemyDeploy)
{
++set %= 10; ++set %= 10;
}
lastEnemyDeploy = set; lastEnemyDeploy = set;
@@ -1087,17 +1089,21 @@ int Game::createBalloon(float x, int y, int kind, float velx, float speed, int c
// Crea una PowerBall // Crea una PowerBall
void Game::createPowerBall() void Game::createPowerBall()
{ {
const int posY = PLAY_AREA_TOP; const int values = 6;
const int posY = PLAY_AREA_TOP - BLOCK;
const int left = PLAY_AREA_LEFT; const int left = PLAY_AREA_LEFT;
const int center = PLAY_AREA_CENTER_X - (BALLOON_WIDTH_4 / 2); const int center = PLAY_AREA_CENTER_X - (BALLOON_WIDTH_4 / 2);
const int right = PLAY_AREA_RIGHT - BALLOON_WIDTH_4; const int right = PLAY_AREA_RIGHT - BALLOON_WIDTH_4;
const int luck = rand() % 3; const float vpos = BALLOON_VELX_POSITIVE;
const int x[3] = {left, center, right}; const float vneg = BALLOON_VELX_NEGATIVE;
const float vx[3] = {BALLOON_VELX_POSITIVE, BALLOON_VELX_POSITIVE, BALLOON_VELX_NEGATIVE};
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 100, balloonTextures[4], balloonAnimations[4], param); const int luck = rand() % values;
const int x[values] = {left, left, center, center, right, right};
const float vx[values] = {vpos, vpos, vpos, vneg, vneg, vneg};
Balloon *b = new Balloon(x[luck], posY, POWER_BALL, vx[luck], enemySpeed, 300, balloonTextures[4], balloonAnimations[4], param);
balloons.push_back(b); balloons.push_back(b);
powerBallEnabled = true; powerBallEnabled = true;
@@ -1907,11 +1913,6 @@ void Game::update()
// Actualiza el contador de ticks // Actualiza el contador de ticks
ticks = SDL_GetTicks(); ticks = SDL_GetTicks();
#ifdef DEBUG
if (counter == 0)
createPowerBall();
#endif
// Actualiza el contador de juego // Actualiza el contador de juego
counter++; counter++;
@@ -2639,15 +2640,6 @@ bool Game::allPlayersAreDead()
// Comprueba los eventos que hay en cola // Comprueba los eventos que hay en cola
void Game::checkEvents() void Game::checkEvents()
{ {
#ifdef DEBUG
const Uint8 *keyStates = SDL_GetKeyboardState(nullptr);
if (keyStates[SDL_SCANCODE_H] != 0)
{
createItemScoreSprite(param->gameWidth / 2, param->gameWidth / 2, n1000Sprite);
}
#endif
while (SDL_PollEvent(eventHandler) != 0) while (SDL_PollEvent(eventHandler) != 0)
{ {
// Evento de salida de la aplicación // Evento de salida de la aplicación
@@ -2659,24 +2651,63 @@ void Game::checkEvents()
else if (eventHandler->type == SDL_WINDOWEVENT) else if (eventHandler->type == SDL_WINDOWEVENT)
{ {
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_LOST) switch (eventHandler->window.event)
{ {
case SDL_WINDOWEVENT_FOCUS_LOST:
if (!demo.enabled) if (!demo.enabled)
{ {
pause(true); pause(true);
} }
} break;
if (eventHandler->window.event == SDL_WINDOWEVENT_FOCUS_GAINED) case SDL_WINDOWEVENT_FOCUS_GAINED:
{
pause(false); pause(false);
} break;
if (eventHandler->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) case SDL_WINDOWEVENT_SIZE_CHANGED:
{
reloadTextures(); reloadTextures();
break;
default:
break;
} }
} }
#ifdef DEBUG
else if (eventHandler->type == SDL_KEYDOWN)
{
switch (eventHandler->key.keysym.sym)
{
case SDLK_h:
createItemScoreSprite(param->gameWidth / 2, param->gameWidth / 2, n1000Sprite);
break;
case SDLK_1:
createPowerBall();
break;
case SDLK_2:
{
const int set = 0;
const stage_t stage = enemyFormations->getStage(0);
const int numEnemies = stage.enemyPool->set[set]->numberOfEnemies;
for (int i = 0; i < numEnemies; ++i)
{
createBalloon(stage.enemyPool->set[set]->init[i].x,
stage.enemyPool->set[set]->init[i].y,
stage.enemyPool->set[set]->init[i].kind,
stage.enemyPool->set[set]->init[i].velX,
enemySpeed,
stage.enemyPool->set[set]->init[i].creationCounter);
}
}
break;
default:
break;
}
}
#endif
} }
} }