Changeset d211210 in network-game for common/Player.cpp
- Timestamp:
- May 9, 2013, 1:32:42 AM (12 years ago)
- Branches:
- master
- Children:
- db58227
- Parents:
- 227baaa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Player.cpp
r227baaa rd211210 95 95 POSITION newPos; 96 96 97 //cout << "pos.x: " << pos.x << endl; 98 //cout << "pos.y: " << pos.y << endl; 99 //cout << "target.x: " << target.x << endl; 100 //cout << "target.y: " << target.y << endl; 101 97 102 if (dist <= pixels) { 98 pos.x = target.x;99 pos.y = target.y;103 newPos.x = target.x; 104 newPos.y = target.y; 100 105 }else { 101 106 newPos.x = int(pos.x + cos(angle)*pixels); 102 107 newPos.y = int(pos.y + sin(angle)*pixels); 108 } 103 109 104 switch(map->getElement(newPos.x/25, newPos.y/25)) { 105 case WorldMap::TERRAIN_NONE: 106 case WorldMap::TERRAIN_ROCK: 107 target.x = pos.x; 108 target.y = pos.y; 109 moveCanceled = true; 110 break; 111 } 110 //cout << "newPos.x: " << newPos.x << endl; 111 //cout << "newPos.y: " << newPos.y << endl; 112 //cout << "newPos.x/25: " << newPos.x/25 << endl; 113 //cout << "newPos.y/25: " << newPos.y/25 << endl; 114 115 switch(map->getElement(newPos.x/25, newPos.y/25)) { 116 case WorldMap::TERRAIN_NONE: 117 case WorldMap::TERRAIN_ROCK: 118 cout << "Encountered invalid terrain" << endl; 119 target.x = pos.x; 120 target.y = pos.y; 121 moveCanceled = true; 122 cout << "move canceled" << endl; 123 break; 124 default: // if there are no obstacles 125 pos.x = newPos.x; 126 pos.y = newPos.y; 127 break; 112 128 } 113 129 } 114 130 115 131 timeLastUpdated = curTime; 132 133 if (moveCanceled) 134 cout << "moveCancled == true" << endl; 135 116 136 return !moveCanceled; 117 137 }
Note:
See TracChangeset
for help on using the changeset viewer.