feat(border): refactor a Graphics::Border amb bumps i flash verd clar per impactes contra les parets
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
|
||||
#include "core/audio/audio.hpp"
|
||||
#include "core/input/input.hpp"
|
||||
#include "core/rendering/line_renderer.hpp"
|
||||
#include "core/system/scene_context.hpp"
|
||||
#include "game/stage_system/stage_loader.hpp"
|
||||
#include "game/systems/collision_system.hpp"
|
||||
@@ -31,7 +30,8 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
floating_score_manager_(sdl.getRenderer()),
|
||||
trail_manager_(sdl.getRenderer()),
|
||||
text_(sdl.getRenderer()),
|
||||
playfield_(sdl.getRenderer()) {
|
||||
playfield_(sdl.getRenderer()),
|
||||
border_(sdl.getRenderer()) {
|
||||
// Recuperar configuración de match des del context
|
||||
match_config_ = context_.getMatchConfig();
|
||||
|
||||
@@ -64,6 +64,17 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
physics_world_.clear();
|
||||
physics_world_.setBounds(Defaults::Zones::PLAYAREA);
|
||||
|
||||
// Connectar els impactes contra les parets al border (bump + flash).
|
||||
physics_world_.setBoundsHitCallback([this](const Physics::BoundsHit& hit) {
|
||||
if (hit.impact_speed < Defaults::Border::BUMP_MIN_VELOCITY) {
|
||||
return;
|
||||
}
|
||||
const float STRENGTH = std::min(
|
||||
1.0F,
|
||||
hit.impact_speed / Defaults::Border::BUMP_VELOCITY_REFERENCE);
|
||||
border_.bumpAt(hit.contact_point, STRENGTH);
|
||||
});
|
||||
|
||||
// Load stage configuration
|
||||
stage_config_ = StageSystem::StageLoader::load("data/stages/stages.yaml");
|
||||
if (!stage_config_) {
|
||||
@@ -183,6 +194,7 @@ void GameScene::stepPhysics(float delta_time) {
|
||||
}
|
||||
trail_manager_.update(delta_time, ships_);
|
||||
playfield_.update(delta_time);
|
||||
border_.update(delta_time);
|
||||
}
|
||||
|
||||
void GameScene::stepShootingInput() {
|
||||
@@ -519,7 +531,7 @@ void GameScene::drawActiveShipsAlive() const {
|
||||
}
|
||||
|
||||
void GameScene::drawContinueState() {
|
||||
drawMargins();
|
||||
border_.draw();
|
||||
drawEnemies();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
@@ -530,7 +542,7 @@ void GameScene::drawContinueState() {
|
||||
}
|
||||
|
||||
void GameScene::drawGameOverState() {
|
||||
drawMargins();
|
||||
border_.draw();
|
||||
drawEnemies();
|
||||
drawBullets();
|
||||
debris_manager_.draw();
|
||||
@@ -601,7 +613,7 @@ void GameScene::drawInitHudState() {
|
||||
|
||||
void GameScene::drawLevelStartState() {
|
||||
playfield_.draw();
|
||||
drawMargins();
|
||||
border_.draw();
|
||||
trail_manager_.draw();
|
||||
drawActiveShipsAlive();
|
||||
drawBullets();
|
||||
@@ -614,7 +626,7 @@ void GameScene::drawLevelStartState() {
|
||||
|
||||
void GameScene::drawPlayingState() {
|
||||
playfield_.draw();
|
||||
drawMargins();
|
||||
border_.draw();
|
||||
trail_manager_.draw();
|
||||
drawActiveShipsAlive();
|
||||
drawEnemies();
|
||||
@@ -627,7 +639,7 @@ void GameScene::drawPlayingState() {
|
||||
|
||||
void GameScene::drawLevelCompletedState() {
|
||||
playfield_.draw();
|
||||
drawMargins();
|
||||
border_.draw();
|
||||
trail_manager_.draw();
|
||||
drawActiveShipsAlive();
|
||||
drawBullets();
|
||||
@@ -679,23 +691,6 @@ void GameScene::tocado(uint8_t player_id) {
|
||||
// Phase 3 is handled in update() when hit_timer_per_player_ >= DEATH_DURATION
|
||||
}
|
||||
|
||||
void GameScene::drawMargins() const {
|
||||
// Dibuixar rectangle de la zona de juego
|
||||
const SDL_FRect& zona = Defaults::Zones::PLAYAREA;
|
||||
|
||||
// Coordenades dels cantons
|
||||
int x1 = static_cast<int>(zona.x);
|
||||
int y1 = static_cast<int>(zona.y);
|
||||
int x2 = static_cast<int>(zona.x + zona.w);
|
||||
int y2 = static_cast<int>(zona.y + zona.h);
|
||||
|
||||
// 4 línies per formar el rectangle
|
||||
Rendering::linea(sdl_.getRenderer(), x1, y1, x2, y1); // Top
|
||||
Rendering::linea(sdl_.getRenderer(), x1, y2, x2, y2); // Bottom
|
||||
Rendering::linea(sdl_.getRenderer(), x1, y1, x1, y2); // Left
|
||||
Rendering::linea(sdl_.getRenderer(), x2, y1, x2, y2); // Right
|
||||
}
|
||||
|
||||
void GameScene::drawScoreboard() {
|
||||
// Construir text del marcador
|
||||
std::string text = buildScoreboard();
|
||||
|
||||
Reference in New Issue
Block a user