From e6eaf870c697e56512b8b7195db31c1d25822204 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 21 May 2026 18:51:55 +0200 Subject: [PATCH] tune(bullets): puja MAX_BALES a 50 i deshardcoded el slot per jugador --- source/core/defaults/entities.hpp | 2 +- source/game/scenes/game_scene.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/core/defaults/entities.hpp b/source/core/defaults/entities.hpp index 4bd5de4..56b5cd1 100644 --- a/source/core/defaults/entities.hpp +++ b/source/core/defaults/entities.hpp @@ -6,7 +6,7 @@ namespace Defaults::Entities { constexpr int MAX_ORNIS = 15; - constexpr int MAX_BALES = 3; + constexpr int MAX_BALES = 50; constexpr float SHIP_RADIUS = 12.0F; constexpr float ENEMY_RADIUS = 20.0F; diff --git a/source/game/scenes/game_scene.cpp b/source/game/scenes/game_scene.cpp index dfaf3cc..fb3136a 100644 --- a/source/game/scenes/game_scene.cpp +++ b/source/game/scenes/game_scene.cpp @@ -850,9 +850,11 @@ void GameScene::fireBullet(uint8_t player_id) { float tip_y = (LOCAL_TIP_X * sin_a) + (LOCAL_TIP_Y * cos_a) + ship_centre.y; Vec2 posicio_dispar = {.x = tip_x, .y = tip_y}; - // Buscar primera bullet inactiva en el pool del player - int start_idx = player_id * 3; // P1=[0,1,2], P2=[3,4,5] - for (int i = start_idx; i < start_idx + 3; i++) { + // Buscar primera bullet inactiva en el pool del player. + // El pool global té MAX_BALES slots per jugador (P1=[0..MAX-1], P2=[MAX..2*MAX-1]). + constexpr int SLOTS_PER_PLAYER = Defaults::Entities::MAX_BALES; + const int START_IDX = player_id * SLOTS_PER_PLAYER; + for (int i = START_IDX; i < START_IDX + SLOTS_PER_PLAYER; i++) { if (!bullets_[i].isActive()) { bullets_[i].disparar(posicio_dispar, ship_angle, player_id); break;