- Timestamp:
- Feb 5, 2013, 7:02:32 PM (12 years ago)
- Branches:
- master
- Children:
- 384b7e0, 60017fc
- Parents:
- 60b77d2
- Location:
- common
- Files:
-
- 2 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
common/Common.h
r60b77d2 r62ee2ce 18 18 int x; 19 19 int y; 20 } P LAYER_POS;20 } POSITION; 21 21 22 22 #endif -
common/Player.h
r60b77d2 r62ee2ce 36 36 string password; 37 37 sockaddr_in addr; 38 P LAYER_POSpos;38 POSITION pos; 39 39 }; 40 40 -
common/WorldMap.cpp
r60b77d2 r62ee2ce 1 #include " Map.h"1 #include "WorldMap.h" 2 2 3 3 using namespace std; 4 4 5 Map::Map(int width, int height)5 WorldMap::WorldMap(int width, int height) 6 6 { 7 7 this->width = width; … … 20 20 } 21 21 22 Map::~Map()22 WorldMap::~WorldMap() 23 23 { 24 24 for (int x=0; x<width; x++) … … 28 28 } 29 29 30 void Map::setElement(int x, int y, TerrainType t) 30 WorldMap::TerrainType WorldMap::getElement(int x, int y) 31 { 32 return (*(*vctMap)[x])[y]; 33 } 34 35 void WorldMap::setElement(int x, int y, TerrainType t) 31 36 { 32 37 (*(*vctMap)[x])[y] = t; 33 38 } 34 39 35 Map*Map::createDefaultMap()40 WorldMap* WorldMap::createDefaultMap() 36 41 { 37 Map* m = new Map(20l, 20);42 WorldMap* m = new WorldMap(12l, 12); 38 43 39 for(int x=0; x< 20; x++)44 for(int x=0; x<12; x++) 40 45 { 41 for(int y=0; y< 20; y++)46 for(int y=0; y<12; y++) 42 47 { 43 if (x ==0 || y == 0 || x == 1 9 || y == 19)48 if (x ==0 || y == 0 || x == 11 || y == 11) 44 49 m->setElement(x, y, TERRAIN_OCEAN); 45 50 else … … 48 53 } 49 54 55 m->setElement(5, 5, TERRAIN_ROCK); 56 50 57 return m; 51 58 } -
common/WorldMap.h
r60b77d2 r62ee2ce 1 #ifndef _ MAP_H2 #define _ MAP_H1 #ifndef _WORLDMAP_H 2 #define _WORLDMAP_H 3 3 4 4 #include <vector> … … 6 6 using namespace std; 7 7 8 class Map {8 class WorldMap { 9 9 public: 10 10 enum TerrainType { 11 11 TERRAIN_NONE, 12 12 TERRAIN_GRASS, 13 TERRAIN_OCEAN 13 TERRAIN_OCEAN, 14 TERRAIN_ROCK 14 15 }; 15 16 … … 17 18 vector<vector<TerrainType>*>* vctMap; 18 19 19 Map(int width, int height);20 WorldMap(int width, int height); 20 21 21 ~ Map();22 ~WorldMap(); 22 23 24 TerrainType getElement(int x, int y); 23 25 void setElement(int x, int y, TerrainType type); 24 26 25 static Map* createDefaultMap();27 static WorldMap* createDefaultMap(); 26 28 }; 27 29
Note:
See TracChangeset
for help on using the changeset viewer.