Fase 1: Migración inicial a C++20 modules
Implementada la estructura base de módulos para vibe2_modules: - Configurado CMakeLists.txt para soportar C++23 y módulos - Creado módulo core.cppm con tipos básicos (Color, ColorTheme, constantes) - Creado módulo sdl_wrapper.cppm para encapsular SDL3 - Migrado defines.h completamente al módulo core - Actualizado ball.h y ball.cpp para usar el módulo core - Actualizado main.cpp para importar y usar el módulo core - Eliminado defines.h obsoleto El proyecto ahora compila y funciona con módulos C++20. Próximos pasos: crear módulos especializados (physics, rendering, etc.) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
57
source/modules/core.cppm
Normal file
57
source/modules/core.cppm
Normal file
@@ -0,0 +1,57 @@
|
||||
export module vibe2.core;
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
export namespace vibe2 {
|
||||
// Constantes de pantalla
|
||||
constexpr char WINDOW_CAPTION[] = "vibe2_modules";
|
||||
constexpr int SCREEN_WIDTH = 320;
|
||||
constexpr int SCREEN_HEIGHT = 240;
|
||||
constexpr int WINDOW_SIZE = 3;
|
||||
constexpr int BALL_SIZE = 10;
|
||||
constexpr float GRAVITY_FORCE = 0.2f;
|
||||
constexpr std::uint64_t TEXT_DURATION = 2000;
|
||||
|
||||
// Tipos básicos
|
||||
struct Color {
|
||||
int r, g, b;
|
||||
|
||||
constexpr Color(int red = 0, int green = 0, int blue = 0)
|
||||
: r(red), g(green), b(blue) {}
|
||||
};
|
||||
|
||||
struct Position {
|
||||
float x, y;
|
||||
|
||||
constexpr Position(float px = 0.0f, float py = 0.0f)
|
||||
: x(px), y(py) {}
|
||||
};
|
||||
|
||||
struct Velocity {
|
||||
float vx, vy;
|
||||
|
||||
constexpr Velocity(float x_vel = 0.0f, float y_vel = 0.0f)
|
||||
: vx(x_vel), vy(y_vel) {}
|
||||
};
|
||||
|
||||
// Enums para el sistema de temas
|
||||
enum class ColorTheme {
|
||||
SUNSET = 0,
|
||||
OCEAN = 1,
|
||||
NEON = 2,
|
||||
FOREST = 3
|
||||
};
|
||||
|
||||
// Constantes útiles para la física
|
||||
namespace physics {
|
||||
constexpr float FRICTION_FACTOR = 0.97f;
|
||||
constexpr float VELOCITY_THRESHOLD = 6.0f;
|
||||
constexpr float CONVERSION_FACTOR = 60.0f; // Frame-based to time-based
|
||||
}
|
||||
|
||||
// Constantes para debug
|
||||
namespace debug {
|
||||
constexpr int DEFAULT_TEXT_SIZE = 8; // Píxeles por carácter
|
||||
constexpr int MARGIN = 8; // Margen por defecto
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user