Files
vibe3_physics/CMakeLists.txt
Sergio Valor f93879b803 Refactor fase 2: Extraer SceneManager de Engine
Migra toda la lógica de gestión de bolas y física a SceneManager
siguiendo el principio de Single Responsibility (SRP).

## Archivos Nuevos

**source/scene/scene_manager.h:**
- Declaración de clase SceneManager
- Gestión de bolas (creación, destrucción, actualización)
- Control de gravedad direccional y estado
- Métodos de acceso: getBalls(), getBallsMutable(), getFirstBall()
- Constructor: SceneManager(screen_width, screen_height)

**source/scene/scene_manager.cpp:**
- Implementación de lógica de escena (~200 líneas)
- changeScenario(): Crea N bolas según escenario
- pushBallsAwayFromGravity(): Impulso direccional
- switchBallsGravity(), forceBallsGravityOn/Off()
- changeGravityDirection(): Cambio de dirección física
- updateBallTexture(): Actualiza textura y tamaño
- updateScreenSize(): Ajusta resolución de pantalla
- updateBallSizes(): Reescala pelotas desde centro

## Archivos Modificados

**source/engine.h:**
- Agregado: #include "scene/scene_manager.h"
- Agregado: std::unique_ptr<SceneManager> scene_manager_
- Removido: std::vector<std::unique_ptr<Ball>> balls_
- Removido: GravityDirection current_gravity_
- Removido: int scenario_
- Removidos métodos privados: initBalls(), switchBallsGravity(),
  enableBallsGravityIfDisabled(), forceBallsGravityOn/Off(),
  changeGravityDirection(), updateBallSizes()

**source/engine.cpp:**
- initialize(): Crea scene_manager_ con resolución
- update(): Delega a scene_manager_->update()
- render(): Usa scene_manager_->getBalls()
- changeScenario(): Delega a scene_manager_
- pushBallsAwayFromGravity(): Delega a scene_manager_
- handleGravityToggle(): Usa scene_manager_->switchBallsGravity()
- handleGravityDirectionChange(): Delega dirección
- switchTextureInternal(): Usa updateBallTexture()
- toggleShapeModeInternal(): Usa getBallsMutable()
- activateShapeInternal(): Usa forceBallsGravityOff()
- updateShape(): Usa getBallsMutable() para asignar targets
- Debug HUD: Usa getFirstBall() para info
- toggleRealFullscreen(): Usa updateScreenSize() + changeScenario()
- performDemoAction(): Delega gravedad y escenarios
- randomizeOnDemoStart(): Delega changeScenario()
- toggleGravityOnOff(): Usa forceBallsGravity*()
- enterLogoMode(): Usa getBallCount() y changeScenario()
- exitLogoMode(): Usa updateBallTexture()
- Removidos ~150 líneas de implementación movidas a SceneManager

**CMakeLists.txt:**
- Agregado source/scene/*.cpp a file(GLOB SOURCE_FILES ...)

## Resultado

- Engine.cpp reducido de 2341 → ~2150 líneas (-191 líneas)
- SceneManager: 202 líneas de lógica de física/escena
- Separación clara: Engine coordina, SceneManager ejecuta física
- 100% funcional: Compila sin errores ni warnings
- Preparado para Fase 3 (UIManager)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-10 11:59:32 +02:00

59 lines
2.0 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(vibe3_physics)
# Establecer el estándar de C++
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Opciones comunes de compilación
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Os -ffunction-sections -fdata-sections")
# Buscar SDL3 automáticamente
find_package(SDL3 REQUIRED)
# Si no se encuentra SDL3, generar un error
if (NOT SDL3_FOUND)
message(FATAL_ERROR "SDL3 no encontrado. Por favor, verifica su instalación.")
endif()
# Buscar SDL3_ttf
find_package(SDL3_ttf REQUIRED)
# Si no se encuentra SDL3_ttf, generar un error
if (NOT SDL3_ttf_FOUND)
message(FATAL_ERROR "SDL3_ttf no encontrado. Por favor, verifica su instalación.")
endif()
# Archivos fuente (excluir main_old.cpp)
file(GLOB SOURCE_FILES source/*.cpp source/external/*.cpp source/input/*.cpp source/scene/*.cpp source/shapes/*.cpp source/themes/*.cpp source/text/*.cpp source/ui/*.cpp)
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_SOURCE_DIR}/source/main_old.cpp")
# Comprobar si se encontraron archivos fuente
if(NOT SOURCE_FILES)
message(FATAL_ERROR "No se encontraron archivos fuente en el directorio 'source/'. Verifica la ruta.")
endif()
# Detectar la plataforma y configuraciones específicas
if(WIN32)
set(PLATFORM windows)
set(LINK_LIBS SDL3::SDL3 SDL3_ttf::SDL3_ttf mingw32 ws2_32)
elseif(UNIX AND NOT APPLE)
set(PLATFORM linux)
set(LINK_LIBS SDL3::SDL3 SDL3_ttf::SDL3_ttf)
elseif(APPLE)
set(PLATFORM macos)
set(LINK_LIBS SDL3::SDL3 SDL3_ttf::SDL3_ttf)
endif()
# Incluir directorios de SDL3 y SDL3_ttf
include_directories(${SDL3_INCLUDE_DIRS} ${SDL3_ttf_INCLUDE_DIRS})
# Añadir el ejecutable reutilizando el nombre del proyecto
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
# Especificar la ubicación del ejecutable (en la raíz del proyecto)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR})
# Enlazar las bibliotecas necesarias
target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})