Browse Source

working

pull/1/head
beta 5 years ago
parent
commit
7b96cd990c
5 changed files with 53 additions and 9 deletions
  1. +2
    -0
      includes/common.hpp
  2. +2
    -2
      includes/game.hpp
  3. +1
    -1
      run.sh
  4. +2
    -3
      source/client.cpp
  5. +46
    -3
      source/game.cpp

+ 2
- 0
includes/common.hpp View File

@ -34,6 +34,8 @@ class Parser
return "ALICE"; return "ALICE";
case BOB: case BOB:
return "BOB"; return "BOB";
case EVE:
return "EVE";
default: default:
return "END"; return "END";
} }

+ 2
- 2
includes/game.hpp View File

@ -36,8 +36,8 @@ private:
const char *TITLE ; const char *TITLE ;
bool KEEP_ALIVE = true; bool KEEP_ALIVE = true;
bool SHOW_GRID = false; bool SHOW_GRID = false;
SHAPE USER_CURRENT = TRIANGLE;
SHAPE GUST_CURRENT = UNKOWN;
SHAPE USER_CURRENT = NONE;
SHAPE GUST_CURRENT = NONE;
MODE ME; MODE ME;
bool KEY_UP_ARROW_ACTIVE = false; bool KEY_UP_ARROW_ACTIVE = false;
bool KEY_DOWN_ARROW_ACTIVE = false; bool KEY_DOWN_ARROW_ACTIVE = false;

+ 1
- 1
run.sh View File

@ -1,2 +1,2 @@
export SDL_VIDEO_X11_VISUALID= export SDL_VIDEO_X11_VISUALID=
./bin/game.out
./bin/game.out 1 4444 localhost

+ 2
- 3
source/client.cpp View File

@ -101,13 +101,12 @@ std::vector Client::explode(std::string &message){
SHAPE Client::parse(const 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) if (result != UNKOWN)
return result; return result;
if (_mode == EVE) if (_mode == EVE)
return UNKOWN; return UNKOWN;
return decode(crypt(tmp));
return decode(crypt(message));
} }
SHAPE Client::decode(const std::string &shape) SHAPE Client::decode(const std::string &shape)
{ {

+ 46
- 3
source/game.cpp View File

@ -17,9 +17,11 @@ Game::Game(MODE mode,
int port, int port,
std::string url): ME(mode) std::string url): ME(mode)
{ {
this->TITLE = Parser::mode(mode).c_str(); 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()) if (init())
{ {
printf("Error loading init\n"); printf("Error loading init\n");
@ -427,6 +429,16 @@ void Game::user_screen()
this->pentagon(); this->pentagon();
break; 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 // 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) void Game::update(SHAPE &s, MODE &m)
{ {
if (m == ME)
if (m == ME || (ME==EVE && m == ALICE))
this->USER_CURRENT = s; this->USER_CURRENT = s;
else else
this->GUST_CURRENT = s; this->GUST_CURRENT = s;
} }
} // namespace betacore } // 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[]) 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; return 0;
} }

Loading…
Cancel
Save