Defaults correctos (sin CLI): - Resolución: 320x240 - Zoom: 3 - Ventana resultante: 960x720 Nuevas funcionalidades: - Parámetro -z/--zoom para especificar zoom de ventana - Si se pasan -w/-h sin -z: zoom automático = 1 - Validación de resolución vs pantalla - Validación de zoom vs max_zoom calculado Lógica de validación: 1. Si resolución > pantalla → reset a 320x240 zoom 3 2. Calcular max_zoom = min(screen_w/width, screen_h/height) 3. Si zoom > max_zoom → ajustar a max_zoom 4. Si CLI con -w/-h pero sin -z → zoom = 1 (auto) Ejemplos: ./vibe3_physics # 320x240 zoom 3 ✅ ./vibe3_physics -w 1920 -h 1080 # 1920x1080 zoom 1 ✅ ./vibe3_physics -w 640 -h 480 -z 2 # 640x480 zoom 2 (1280x960) ✅ ./vibe3_physics -w 9999 -h 9999 # Reset a default (warning) ✅ Archivos: - defines.h: Renombrar WINDOW_ZOOM → DEFAULT_WINDOW_ZOOM - main.cpp: Añadir parsing -z/--zoom - engine.h: initialize() acepta zoom - engine.cpp: Validación + advertencias informativas 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
86 lines
3.1 KiB
C++
86 lines
3.1 KiB
C++
#include <iostream>
|
|
#include <cstring>
|
|
#include "engine.h"
|
|
|
|
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: 320)\n";
|
|
std::cout << " -h, --height <px> Alto de resolución (default: 240)\n";
|
|
std::cout << " -z, --zoom <n> Zoom de ventana (default: 3)\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 # 320x240 zoom 3 (ventana 960x720)\n";
|
|
std::cout << " vibe3_physics -w 1920 -h 1080 # 1920x1080 zoom 1 (auto)\n";
|
|
std::cout << " vibe3_physics -w 640 -h 480 -z 2 # 640x480 zoom 2 (ventana 1280x960)\n";
|
|
std::cout << " vibe3_physics -w 1920 -h 1080 -f # 1920x1080 fullscreen\n\n";
|
|
std::cout << "Nota: Si resolución > pantalla, se usa default. Zoom se ajusta automáticamente.\n";
|
|
}
|
|
|
|
int main(int argc, char* argv[]) {
|
|
int width = 0;
|
|
int height = 0;
|
|
int zoom = 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], "-z") == 0 || strcmp(argv[i], "--zoom") == 0) {
|
|
if (i + 1 < argc) {
|
|
zoom = atoi(argv[++i]);
|
|
if (zoom < 1) {
|
|
std::cerr << "Error: Zoom mínimo es 1\n";
|
|
return -1;
|
|
}
|
|
} else {
|
|
std::cerr << "Error: -z/--zoom 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(width, height, zoom, fullscreen)) {
|
|
std::cout << "¡Error al inicializar el engine!" << std::endl;
|
|
return -1;
|
|
}
|
|
|
|
engine.run();
|
|
engine.shutdown();
|
|
|
|
return 0;
|
|
} |