Line data Source code
1 : #include <iostream> 2 : #include <client.hpp> 3 : #include <shared.hpp> 4 : 5 0 : int main(int argc, char *argv[]) 6 : { 7 0 : std::string arg; 8 0 : if (argc != 2) 9 : { 10 0 : std::cout << "Unkown command, use -h for help." << std::endl; 11 : } 12 : else 13 : { 14 0 : arg = argv[1]; 15 0 : if (!arg.compare("-h")) 16 : { 17 0 : std::cout << "Usage: " << argv[0] << " [command]" << std::endl; 18 0 : std::cout << "Commands:" << std::endl; 19 0 : std::cout << " -h\t\t\tShow this help" << std::endl; 20 0 : std::cout << " -r\t\t\tStart client" << std::endl; 21 0 : std::cout << " hello\t\t\tPrint hello world" << std::endl; 22 0 : std::cout << " -n\t\t\tStart network client" << std::endl; 23 : } 24 0 : else if (arg.compare("-r") == 0 || arg.compare("render") == 0) 25 : { 26 0 : client::ClientGameEngine clientGameEngine; 27 0 : clientGameEngine.renderGame(); 28 0 : std::cout << "Thanks for playing our game !" << std::endl; 29 0 : } 30 0 : else if (arg.compare("hello") == 0) 31 : { 32 0 : std::cout << "Hello world" << std::endl; 33 : } 34 0 : else if (arg.compare("-n") == 0 || arg.compare("network") == 0) 35 : { 36 0 : client::ClientGameEngine maGame; 37 0 : maGame.connect("127.0.0.1", 8080); 38 : while(true) 39 : { 40 0 : sleep(3); 41 0 : std::unique_lock<std::mutex> lock(maGame.myself->qAndA.sharedDataMutex); 42 0 : maGame.myself->qAndA.question = "getstate\n"; 43 0 : lock.unlock(); 44 0 : maGame.askServer(); 45 0 : std::cout << maGame.myself->qAndA.answer << std::endl; 46 : 47 0 : } 48 0 : } 49 : else 50 : { 51 0 : std::cout << "Unkown command, use -h for help." << std::endl; 52 : } 53 : } 54 0 : exit(0); 55 0 : }