1
0
game/client/config.hpp

65 lines
2.1 KiB
C++

#pragma once
#include <iostream>
#include <string>
struct GameConfig {
// Terrain configuration
std::string heightmapFile = "../assets/heightmap.bin";
float unitsPerSample = 1.0f; // Meters per heightmap sample
float heightScale = 1.0f; // Height multiplier
// Window configuration
int windowWidth = 1280;
int windowHeight = 720;
std::string windowTitle = "Game";
int targetFPS = 60;
// Movement
float moveSpeed = 15.0f;
// Network
float heartbeatInterval = 5.0f;
// Debug options
bool showDebugInfo = false;
// Load configuration from command line args or config file
static GameConfig fromArgs(int argc, char* argv[]) {
GameConfig config;
// Parse command line arguments
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
if (arg == "--heightmap" && i + 1 < argc) {
config.heightmapFile = argv[++i];
} else if (arg == "--scale" && i + 1 < argc) {
config.unitsPerSample = std::stof(argv[++i]);
} else if (arg == "--height-scale" && i + 1 < argc) {
config.heightScale = std::stof(argv[++i]);
} else if (arg == "--debug") {
config.showDebugInfo = true;
} else if (arg == "--help") {
printHelp();
exit(0);
}
}
return config;
}
private:
static void printHelp() {
std::cout << "Game Options:\n";
std::cout << " --heightmap <file> Load specific heightmap file\n";
std::cout << " --scale <value> Units per heightmap sample (default: 1.0)\n";
std::cout << " --height-scale <val> Height multiplier (default: 1.0)\n";
std::cout << " --debug Show debug information\n";
std::cout << " --help Show this help\n";
std::cout << "\nExamples:\n";
std::cout << " ./game --heightmap ../assets/heightmap_small.bin\n";
std::cout << " ./game --heightmap ../assets/heightmap_large.bin --scale 2.0\n";
}
};