Añadir parámetro -z/--zoom con validación inteligente
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>
This commit is contained in:
@@ -6,19 +6,23 @@ 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 << " -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 # 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";
|
||||
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
|
||||
@@ -48,6 +52,17 @@ int main(int argc, char* argv[]) {
|
||||
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 {
|
||||
@@ -59,7 +74,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
Engine engine;
|
||||
|
||||
if (!engine.initialize(width, height, fullscreen)) {
|
||||
if (!engine.initialize(width, height, zoom, fullscreen)) {
|
||||
std::cout << "¡Error al inicializar el engine!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user