Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
Administrator
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
ParameterMap pm; pm["level"] = "Great Showdown at Grand Canyon"; pm["numPlayers"] = 4; pm["botDifficulty"] = 8.2f; app.pushGameState("Game", pm); |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
void GS_Game::onEnter(const ParameterMap& pm) { const char* p_level = pm.get<const char*>("level"); int numPlayers = pm.get<int>("numPlayers"); float botDifficulty = pm.get<float>("botDifficulty"); // ... } |
Anonymous
unregistriert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// I N C L U D E S ########################################################### // standard includes #include <string> #include <map> // System specific includes #if defined (_WIN32) #include <windows.h> #include <tchar.h> #endif // D E F I N I T I O N S ##################################################### // non-win32-platforms #if !defined (_WIN32) typedef char TCHAR; #define _T(value) ##value #endif // string-class typedef std::basic_string<::TCHAR> string_type; // T E S T S ################################################################## // define registry std::map<::string_type, ::string_type> registry; // [...] // set values registry[_T ("wert1")] = _T ("hallo"); registry[_T ("wert2")] = _T ("welt!"); registry[_T ("value")] = _T ("12345"); // get values string_type hallo = registry[_T ("wert1")]; string_type welt = registry[_T ("wert2")]; int value = lexical_cast<int>(registry[_T ("value")]); |
Zitat von »"David Scherfgen"«
Ich mache sowas mit einer Parameter-Map
C-/C++-Quelltext |
|
1 2 3 4 5 6 |
struct settings { int spielerzahl; string map; ... } |
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 |
class IPara { } class GamePara : public IPara { } setGameState(GAMESTATE GS, IPara para); |
Anonymous
unregistriert
Werbeanzeige