Changeset 0129700 in network-game
- Timestamp:
- Dec 19, 2013, 3:31:45 AM (11 years ago)
- Branches:
- master
- Children:
- fef7c69
- Parents:
- 70fc3e8
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Game.cpp
r70fc3e8 r0129700 67 67 } 68 68 69 bool Game::startPlayerMovement(unsigned int id, int x, int y) { 70 // need to check if players actually contains the id 71 Player* p = players[id]; 72 73 // we need to make sure the player can move here 74 if (0 <= x && x < this->worldMap->width*25 && 75 0 <= y && y < this->worldMap->height*25 && 76 this->worldMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS) 77 { 78 p->target.x = x; 79 p->target.y = y; 80 81 p->isChasing = false; 82 p->isAttacking = false; 83 84 return true; 85 } 86 else 87 return false; 88 } 89 69 90 void Game::setRedScore(int score) { 70 91 this->redScore = score; -
common/Game.h
r70fc3e8 r0129700 41 41 bool addPlayer(Player* p); 42 42 bool removePlayer(unsigned int id); 43 bool startPlayerMovement(unsigned int id, int x, int y); 43 44 void setBlueScore(int score); 44 45 void setRedScore(int score); -
server/server.cpp
r70fc3e8 r0129700 818 818 p->addr.sin_port == from.sin_port ) 819 819 { 820 // we need to make sure the player can move here 821 if (0 <= x && x < gameMap->width*25 && 0 <= y && y < gameMap->height*25 && 822 gameMap->getElement(x/25, y/25) == WorldMap::TERRAIN_GRASS) 823 { 824 cout << "valid terrain" << endl; 825 826 p->target.x = x; 827 p->target.y = y; 828 829 p->isChasing = false; 830 p->isAttacking = false; 831 820 if (p->currentGame->startPlayerMovement(id, x, y)) { 832 821 serverMsg.type = MSG_TYPE_PLAYER_MOVE; 833 822
Note:
See TracChangeset
for help on using the changeset viewer.