Changeset e76055f in network-game for common


Ignore:
Timestamp:
May 18, 2013, 8:50:33 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
e4a5786
Parents:
d69eb32
Message:

The server now checks if a player got close enough to a flag to pick it up

Location:
common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/Player.cpp

    rd69eb32 re76055f  
    113113      }
    114114
    115       //cout << "newPos.x: " << newPos.x << endl;
    116       //cout << "newPos.y: " << newPos.y << endl;
    117       //cout << "newPos.x/25: " << newPos.x/25 << endl;
    118       //cout << "newPos.y/25: " << newPos.y/25 << endl;
    119 
    120115      switch(map->getElement(newPos.x/25, newPos.y/25)) {
    121116      case WorldMap::TERRAIN_NONE:
     117      case WorldMap::TERRAIN_OCEAN:
    122118      case WorldMap::TERRAIN_ROCK:
    123119         cout << "Encountered invalid terrain" << endl;
     
    132128         break;
    133129      }
     130
     131      // using moveCanceled in a hacky way just to indicate that the server
     132      // has updated some player info. Should change the variable name
     133      switch(map->getObject(newPos.x/25, newPos.y/25)) {
     134      case WorldMap::OBJECT_BLUE_FLAG:
     135         hasBlueFlag = true;
     136         moveCanceled = true;
     137         break;
     138      case WorldMap::OBJECT_RED_FLAG:
     139         hasRedFlag = true;
     140         moveCanceled = true;
     141         break;
     142      }
    134143   }
    135144
  • common/WorldMap.h

    rd69eb32 re76055f  
    1919   enum ObjectType {
    2020      OBJECT_NONE,
    21       OBJECT_RED_FLAG,
    22       OBJECT_BLUE_FLAG
     21      OBJECT_BLUE_FLAG,
     22      OBJECT_RED_FLAG
    2323   };
    2424
Note: See TracChangeset for help on using the changeset viewer.