- Timestamp:
- Oct 1, 2013, 8:08:24 PM (11 years ago)
- Branches:
- master
- Children:
- 95ffe57
- Parents:
- 373089e
- Location:
- common
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Common.h
r373089e re6c26b8 1 1 #ifndef _COMMON_H 2 2 #define _COMMON_H 3 4 #include "Compiler.h"5 6 #if defined WINDOWS7 #include <winsock2.h>8 #include <ws2tcpip.h>9 #elif defined LINUX10 #include <fcntl.h>11 #include <assert.h>12 #endif13 3 14 4 #include <string> -
common/MessageContainer.h
r373089e re6c26b8 4 4 #include <string> 5 5 6 #include "Com mon.h"6 #include "Compiler.h" 7 7 8 #if defined LINUX 8 #if defined WINDOWS 9 #include <winsock2.h> 10 #elif defined LINUX 9 11 #include <netinet/in.h> 10 12 #endif -
common/MessageProcessor.cpp
r373089e re6c26b8 3 3 #include <iostream> 4 4 #include <fstream> 5 6 #include "Compiler.h" 7 8 #if defined WINDOWS 9 #include <ws2tcpip.h> 10 #endif 11 12 #include "Common.h" 5 13 6 14 MessageProcessor::MessageProcessor() { -
common/Player.cpp
r373089e re6c26b8 206 206 } 207 207 208 bool Player::updateTarget(map<unsigned int, Player >& mapPlayers) {208 bool Player::updateTarget(map<unsigned int, Player*>& mapPlayers) { 209 209 if (this->isChasing) { 210 this->target.x = mapPlayers[this->targetPlayer] .pos.x;211 this->target.y = mapPlayers[this->targetPlayer] .pos.y;210 this->target.x = mapPlayers[this->targetPlayer]->pos.x; 211 this->target.y = mapPlayers[this->targetPlayer]->pos.y; 212 212 213 213 if (posDistance(this->pos, this->target.toFloat()) <= this->range) { -
common/Player.h
r373089e re6c26b8 5 5 #include <map> 6 6 7 #include "Com mon.h"7 #include "Compiler.h" 8 8 9 #if defined LINUX 9 #if defined WINDOWS 10 #include <winsock2.h> 11 #elif defined LINUX 10 12 #include <netinet/in.h> 11 13 #endif … … 46 48 void deserialize(char* buffer); 47 49 48 bool updateTarget(map<unsigned int, Player >& mapPlayers);50 bool updateTarget(map<unsigned int, Player*>& mapPlayers); 49 51 bool move(WorldMap *map); 50 52 -
common/Projectile.cpp
r373089e re6c26b8 71 71 } 72 72 73 bool Projectile::move(map<unsigned int, Player >& mapPlayers) {73 bool Projectile::move(map<unsigned int, Player*>& mapPlayers) { 74 74 // if the current target logs off, this method will run into problems 75 75 76 76 unsigned long long curTime = getCurrentMillis(); 77 77 78 Player targetP = mapPlayers[target];78 Player* targetP = mapPlayers[target]; 79 79 80 80 if (timeLastUpdated == 0) { … … 85 85 86 86 float pixels = speed * (curTime-timeLastUpdated) / 1000.0; 87 double angle = atan2(targetP .pos.y-pos.y, targetP.pos.x-pos.x);88 float dist = sqrt(pow(targetP .pos.x-pos.x, 2) + pow(targetP.pos.y-pos.y, 2));87 double angle = atan2(targetP->pos.y-pos.y, targetP->pos.x-pos.x); 88 float dist = sqrt(pow(targetP->pos.x-pos.x, 2) + pow(targetP->pos.y-pos.y, 2)); 89 89 90 90 if (dist <= pixels) { 91 pos.x = targetP .pos.x;92 pos.y = targetP .pos.y;91 pos.x = targetP->pos.x; 92 pos.y = targetP->pos.y; 93 93 return true; 94 94 }else { -
common/Projectile.h
r373089e re6c26b8 26 26 27 27 // returns true if it reached the target and should be deleted 28 bool move(map<unsigned int, Player>& mapPlayers); 28 bool move(map<unsigned int, Player*>& mapPlayers); 29 30 /* 31 * target should become a Player*. When this object gets serialized, the player's id should be sent. 32 * Deserialization in this case might be tricky since it will require a playerMap to turn the id into a Plauyer* 33 */ 29 34 30 35 int id;
Note:
See TracChangeset
for help on using the changeset viewer.