diff --git a/includes/common.hpp b/includes/common.hpp index 6940944..71ce1fa 100644 --- a/includes/common.hpp +++ b/includes/common.hpp @@ -34,6 +34,8 @@ class Parser return "ALICE"; case BOB: return "BOB"; + case EVE: + return "EVE"; default: return "END"; } diff --git a/includes/game.hpp b/includes/game.hpp index f9ad597..ced64fb 100644 --- a/includes/game.hpp +++ b/includes/game.hpp @@ -36,8 +36,8 @@ private: const char *TITLE ; bool KEEP_ALIVE = true; bool SHOW_GRID = false; - SHAPE USER_CURRENT = TRIANGLE; - SHAPE GUST_CURRENT = UNKOWN; + SHAPE USER_CURRENT = NONE; + SHAPE GUST_CURRENT = NONE; MODE ME; bool KEY_UP_ARROW_ACTIVE = false; bool KEY_DOWN_ARROW_ACTIVE = false; diff --git a/run.sh b/run.sh index 3c32e76..8dbdb74 100644 --- a/run.sh +++ b/run.sh @@ -1,2 +1,2 @@ export SDL_VIDEO_X11_VISUALID= -./bin/game.out \ No newline at end of file +./bin/game.out 1 4444 localhost \ No newline at end of file diff --git a/source/client.cpp b/source/client.cpp index a1174cf..bcbdf13 100644 --- a/source/client.cpp +++ b/source/client.cpp @@ -101,13 +101,12 @@ std::vector Client::explode(std::string &message){ SHAPE Client::parse(const std::string &message) { - std::string tmp = message; - SHAPE result = decode(tmp); + SHAPE result = decode(message); if (result != UNKOWN) return result; if (_mode == EVE) return UNKOWN; - return decode(crypt(tmp)); + return decode(crypt(message)); } SHAPE Client::decode(const std::string &shape) { diff --git a/source/game.cpp b/source/game.cpp index 692420d..f2cd3cd 100644 --- a/source/game.cpp +++ b/source/game.cpp @@ -17,9 +17,11 @@ Game::Game(MODE mode, int port, std::string url): ME(mode) { + this->TITLE = Parser::mode(mode).c_str(); - printf("%s\t%d\t%d\n",this->TITLE, this->MONITOR_WIDTH, this->MONITOR_HEIGHT); + printf("%s\t%s\t%d\t%d\n",this->TITLE, Parser::mode(mode).c_str(), + this->MONITOR_WIDTH, this->MONITOR_HEIGHT); if (init()) { printf("Error loading init\n"); @@ -427,6 +429,16 @@ void Game::user_screen() this->pentagon(); break; + case UNKOWN: + float gray = 105.0 / 255.0; + glColor3f(gray, gray, gray); + glPushMatrix(); + glRotatef(-45.0f, 0.0f, 0.0f, 1.0f); + glScalef(2.0f, 2.0f, 0.0f); + + this->cross(true); + glPopMatrix(); + break; } // glTranslatef(3.0f, 0.0f, 0.0f); // Move Right 3 Units @@ -697,15 +709,46 @@ void Game::on_key_enter() } void Game::update(SHAPE &s, MODE &m) { - if (m == ME) + if (m == ME || (ME==EVE && m == ALICE)) this->USER_CURRENT = s; else this->GUST_CURRENT = s; } } // namespace betacore + +void ussage(){ + std::cout + << "Ussage:\n" + << "\tMODE: 1-3\n" + << "\t\t1)Alice\n" + << "\t\t2)Bob\n" + << "\t\t2)Eve\n" + << "\tport\n" + << "\taddress" + << std::endl; +} int main(int argc, char *argv[]) { - betacore::Game game(betacore::BOB, 4444, "localhost"); + + if(argc < 4){ + ussage(); + return 1; + } + betacore::MODE mode = betacore::EVE; + int a = atoi(argv[1]); + std::cout << "Running mode" << a << std::endl; + switch( a){ + case 1: + mode = betacore::ALICE; + break; + case 2: + mode = betacore::BOB; + break; + default: + mode = betacore::EVE; + break; + } + betacore::Game game(mode, atoi(argv[2]),argv[3]); return 0; } \ No newline at end of file