refactor(shapes): reorganitzar data/shapes en subcarpetes per categoria (enemy/bullet/ship/effect)
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Graphics {
|
||||
return it->second; // Cache hit
|
||||
}
|
||||
|
||||
// Normalize path: "ship.shp" → "shapes/ship.shp"
|
||||
// Normalize path: "ship/arrow.shp" → "shapes/ship/arrow.shp"
|
||||
// "logo/letra_j.shp" → "shapes/logo/letra_j.shp"
|
||||
std::string normalized = filename;
|
||||
if (!normalized.starts_with("shapes/")) {
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Graphics {
|
||||
|
||||
// Carregar shape desde file (con caché)
|
||||
// Retorna punter compartit (nullptr si error)
|
||||
// Exemple: load("ship.shp") → busca a "data/shapes/ship.shp"
|
||||
// Exemple: load("ship/arrow.shp") → busca a "data/shapes/ship/arrow.shp"
|
||||
static auto load(const std::string& filename) -> std::shared_ptr<Shape>;
|
||||
|
||||
// Netejar caché (útil per debug/recàrrega)
|
||||
|
||||
@@ -33,9 +33,9 @@ namespace Effects {
|
||||
|
||||
TrailManager::TrailManager(Rendering::Renderer* renderer)
|
||||
: renderer_(renderer),
|
||||
star_shape_(Graphics::ShapeLoader::load("star.shp")) {
|
||||
star_shape_(Graphics::ShapeLoader::load("effect/starfield.shp")) {
|
||||
if (!star_shape_ || !star_shape_->isValid()) {
|
||||
std::cerr << "[TrailManager] Warning: no s'ha pogut load star.shp\n";
|
||||
std::cerr << "[TrailManager] Warning: no s'ha pogut load effect/starfield.shp\n";
|
||||
}
|
||||
for (auto& particle : pool_) {
|
||||
particle.active = false;
|
||||
|
||||
@@ -26,7 +26,7 @@ Ship::Ship(Rendering::Renderer* renderer, PlayerConfig config, const char* shape
|
||||
config_(std::move(config)) {
|
||||
brightness_ = Defaults::Brightness::NAU;
|
||||
|
||||
// El shape pot venir del YAML o ser overridden (ex: P2 amb "ship2.shp").
|
||||
// El shape pot venir del YAML o ser overridden (ex: P2 amb "ship/wedge.shp").
|
||||
const std::string SHAPE_PATH = (shape_override != nullptr) ? shape_override : config_.shape.path;
|
||||
shape_ = Graphics::ShapeLoader::load(SHAPE_PATH);
|
||||
if (!shape_ || !shape_->isValid()) {
|
||||
|
||||
@@ -82,8 +82,8 @@ GameScene::GameScene(SDLManager& sdl, SceneContext& context)
|
||||
}
|
||||
|
||||
// Inicialitzar naves: P1 amb el shape del YAML, P2 amb override visual.
|
||||
ships_[0] = Ship(sdl.getRenderer(), *player_config); // Jugador 1: nau estàndard
|
||||
ships_[1] = Ship(sdl.getRenderer(), *player_config, "ship2.shp"); // Jugador 2: interceptor amb ales
|
||||
ships_[0] = Ship(sdl.getRenderer(), *player_config); // Jugador 1: nau estàndard
|
||||
ships_[1] = Ship(sdl.getRenderer(), *player_config, "ship/wedge.shp"); // Jugador 2: triangle amb cercle central
|
||||
|
||||
// Inicialitzar balas con renderer
|
||||
std::ranges::fill(bullets_, Bullet(sdl.getRenderer()));
|
||||
|
||||
@@ -78,7 +78,7 @@ TitleScene::TitleScene(SDLManager& sdl, SceneContext& context)
|
||||
|
||||
// Flash que tapa el "pop" final de la nau al VP. Es spawneja al centre
|
||||
// de pantalla (= projecció del VP) quan ship_animator avisa.
|
||||
flash_shape_ = Graphics::ShapeLoader::load("title_flash.shp");
|
||||
flash_shape_ = Graphics::ShapeLoader::load("effect/title_flash.shp");
|
||||
ship_animator_->setOnShipDisappear([this](int /*player_id*/) {
|
||||
triggerFlash(Vec2{
|
||||
.x = static_cast<float>(Defaults::Window::WIDTH) / 2.0F,
|
||||
|
||||
@@ -114,8 +114,8 @@ namespace Title {
|
||||
}
|
||||
|
||||
void ShipAnimator::init() {
|
||||
auto shape_p1 = Graphics::ShapeLoader::load("ship.shp");
|
||||
auto shape_p2 = Graphics::ShapeLoader::load("ship2.shp");
|
||||
auto shape_p1 = Graphics::ShapeLoader::load("ship/arrow.shp");
|
||||
auto shape_p2 = Graphics::ShapeLoader::load("ship/wedge.shp");
|
||||
|
||||
ships_[0].player_id = 1;
|
||||
if (shape_p1 && shape_p1->isValid()) {
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
//
|
||||
// Manté la mateixa màquina d'estats
|
||||
// (ENTERING → FLOATING → EXITING) però treballa amb posicions Vec3 i emet
|
||||
// wireframes a través d'una `Camera3D`. La geometria s'extrau de `ship.shp`
|
||||
// (P1) i `ship2.shp` (P2) per extrusió en Z.
|
||||
// wireframes a través d'una `Camera3D`. La geometria s'extrau de
|
||||
// `ship/arrow.shp` (P1) i `ship/wedge.shp` (P2) per extrusió en Z.
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
Reference in New Issue
Block a user