diff --git a/config.yml b/config.yml index c3ff9ba..6c64c0b 100644 --- a/config.yml +++ b/config.yml @@ -5,21 +5,21 @@ players: speed: 1 user1: color: red - keys: - left: 4 - right: 6 - shoot: 5 - user2: - color: blue keys: left: q right: d shoot: s + user2: + color: blue + keys: + left: 4 + right: 6 + shoot: 5 # Enemies config invaders: - size: 4 + size: 15 speed: 2 distance: 10 # distance in pixels between invaders diff --git a/headers/errors.h b/headers/errors.h new file mode 100644 index 0000000..1cd82c1 --- /dev/null +++ b/headers/errors.h @@ -0,0 +1,6 @@ +#ifndef SPACE_ERRORS_H +#define SPACE_ERRORS_H + + + +#endif diff --git a/src/configManagement.cpp b/src/configManagement.cpp index bb56c34..1ff8118 100644 --- a/src/configManagement.cpp +++ b/src/configManagement.cpp @@ -6,10 +6,9 @@ public: ConfigData collectedData; void parseFile(const string& fname); void readConfig(); - + void dumpInternalValues(); private: map internalValues; - string& getString(const configKey& key); char getChar(const configKey& key); int getInt(const configKey& key); @@ -17,6 +16,12 @@ private: }; +void ConfigBuilder::dumpInternalValues(){ + for(const auto& ite : internalValues){ + cerr << ite.first << " -> " << ite.second << endl; + } +} + void trimSpaces(string& str){ str.erase(0, str.find_first_not_of(' ')); } @@ -36,7 +41,6 @@ void ConfigBuilder::parseFile(const string& fname) { unsigned currentIndent = 0; while (line[currentIndent] == ' ')++currentIndent; - match = line.find(':'); if (match == string::npos)throw runtime_error("Invalid line : " + line); string key = line.substr(0, match); @@ -150,8 +154,13 @@ bool Game::reloadConfig() { builder.readConfig(); }catch(runtime_error& e){ if(parsed)cerr << "An error occured while reading the configuration :" << endl; - else cerr << "An error occured while parsind the configuration :" << endl; + else cerr << "An error occured while parsing the configuration :" << endl; cerr << e.what() << endl; + if(parsed){ + cerr << "Parsed keys :" << endl; + builder.dumpInternalValues(); + } + cerr << "(The old configuration was kept in memory)" << endl; return false; } confData = builder.collectedData; diff --git a/src/game_basics.cpp b/src/game_basics.cpp index fbfb35b..2c21dd7 100644 --- a/src/game_basics.cpp +++ b/src/game_basics.cpp @@ -40,7 +40,12 @@ PlayMode Game::initialMenuHandler(){ case 0:{ return PlayMode::SINGLE; } - // potential options... + case 1:{ + return PlayMode::TWO_LOCAL; + } + case 2:{ + return PlayMode::TWO_TCPIP; + } } return PlayMode::EXIT; } @@ -64,7 +69,7 @@ bool Game::invadersTouchPlayer(){ /** * Plays the game, and returns once the game is finished * - * @return WinValue::PLAYERS if the players won, WinValue::INVADERS is the invaders won, WinValue::NOBODY else (also in case of error) + * @return @WinValue::PLAYERS if the players won, @WinValue::INVADERS is the invaders won, WinValue::NOBODY else (also in case of error) */ WinValue Game::playGame(){ // returns when game is finished // INIT diff --git a/src/game_managers.cpp b/src/game_managers.cpp index f3e1d54..1fc8781 100644 --- a/src/game_managers.cpp +++ b/src/game_managers.cpp @@ -42,7 +42,7 @@ bool Game::manageInvaders(){ if(end + confData.invadersSpeed < pm.getScreenWidth()){ basePos.setX(basePos.getX() + confData.invadersSpeed); }else{ - basePos.setY(basePos.getY() + confData.invadersSize); + basePos.setY(basePos.getY() + confData.invadersSize + confData.invadersDistance); direction = !direction; return true; } @@ -50,7 +50,7 @@ bool Game::manageInvaders(){ if(basePos.getX() >= confData.invadersSpeed){ basePos.setX(basePos.getX() - confData.invadersSpeed); }else{ - basePos.setY(basePos.getY() + confData.invadersSize); + basePos.setY(basePos.getY() + confData.invadersSize + confData.invadersDistance); direction = !direction; return true; } diff --git a/src/pixel_manager.cpp b/src/pixel_manager.cpp index 4e3871e..0096af8 100644 --- a/src/pixel_manager.cpp +++ b/src/pixel_manager.cpp @@ -51,7 +51,7 @@ void PixelManager::dessinerSprite(const nsGraphics::Vec2D& baseVector, const std } unsigned PixelManager::showInitialMenu(){ - return 0; + return 1; } unsigned PixelManager::showDeathMenu() {