Añadir parámetros de línea de comandos para resolución

Características:
- Parámetros CLI: -w/--width, -h/--height, -f/--fullscreen
- Help: --help muestra uso y ejemplos
- Validación: mínimo 640x480, con mensajes de error
- Defaults: 1280x720 ventana si no se especifica
- Fullscreen opcional con flag -f

Ejemplos de uso:
  ./vibe3_physics                    # Default 1280x720
  ./vibe3_physics -w 1920 -h 1080    # Personalizado
  ./vibe3_physics -w 1920 -h 1080 -f # Fullscreen
  ./vibe3_physics --help             # Ayuda

Archivos modificados:
- source/main.cpp: Parser de argumentos + printHelp()
- source/engine.h: initialize() acepta parámetros
- source/engine.cpp: Lógica de ventana configurable
- ROADMAP.md: Marcar tarea completada

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-04 13:28:44 +02:00
parent 0f0617066e
commit c4ca49b006
4 changed files with 88 additions and 17 deletions

View File

@@ -1,11 +1,65 @@
#include <iostream>
#include <cstring>
#include "engine.h"
int main() {
void printHelp() {
std::cout << "ViBe3 Physics - Simulador de físicas avanzadas\n";
std::cout << "\nUso: vibe3_physics [opciones]\n\n";
std::cout << "Opciones:\n";
std::cout << " -w, --width <px> Ancho de resolución (default: 1280)\n";
std::cout << " -h, --height <px> Alto de resolución (default: 720)\n";
std::cout << " -f, --fullscreen Modo pantalla completa\n";
std::cout << " --help Mostrar esta ayuda\n\n";
std::cout << "Ejemplos:\n";
std::cout << " vibe3_physics # 1280x720 ventana\n";
std::cout << " vibe3_physics -w 1920 -h 1080 # 1920x1080 ventana\n";
std::cout << " vibe3_physics -w 1920 -h 1080 -f # 1920x1080 fullscreen\n";
}
int main(int argc, char* argv[]) {
int width = 0;
int height = 0;
bool fullscreen = false;
// Parsear argumentos
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "--help") == 0) {
printHelp();
return 0;
} else if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "--width") == 0) {
if (i + 1 < argc) {
width = atoi(argv[++i]);
if (width < 640) {
std::cerr << "Error: Ancho mínimo es 640px\n";
return -1;
}
} else {
std::cerr << "Error: -w/--width requiere un valor\n";
return -1;
}
} else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--height") == 0) {
if (i + 1 < argc) {
height = atoi(argv[++i]);
if (height < 480) {
std::cerr << "Error: Alto mínimo es 480px\n";
return -1;
}
} else {
std::cerr << "Error: -h/--height requiere un valor\n";
return -1;
}
} else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--fullscreen") == 0) {
fullscreen = true;
} else {
std::cerr << "Error: Opción desconocida '" << argv[i] << "'\n";
printHelp();
return -1;
}
}
Engine engine;
if (!engine.initialize()) {
if (!engine.initialize(width, height, fullscreen)) {
std::cout << "¡Error al inicializar el engine!" << std::endl;
return -1;
}