Changeset 05051c7 in network-game for common/WorldMap.cpp
- Timestamp:
- May 19, 2013, 7:12:07 PM (12 years ago)
- Branches:
- master
- Children:
- cc1c6c1
- Parents:
- 035d852
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/WorldMap.cpp
r035d852 r05051c7 15 15 16 16 vctMap = new vector<vector<TerrainType>*>(width); 17 vctObjects = new vector<vector<ObjectType>*>(width); 17 vctStructures = new vector<vector<StructureType>*>(width); 18 vctObjects = new vector<Object>(); 18 19 19 20 for (int x=0; x<width; x++) { 20 21 vector<TerrainType>* newMapVector = new vector<TerrainType>(height); 21 vector< ObjectType>* newObjectVector = new vector<ObjectType>(height);22 vector<StructureType>* newStructureVector = new vector<StructureType>(height); 22 23 23 24 for (int y=0; y<height; y++) { 24 25 (*newMapVector)[y] = TERRAIN_NONE; 25 (*new ObjectVector)[y] = OBJECT_NONE;26 (*newStructureVector)[y] = STRUCTURE_NONE; 26 27 } 27 28 28 29 (*vctMap)[x] = newMapVector; 29 (*vct Objects)[x] = newObjectVector;30 (*vctStructures)[x] = newStructureVector; 30 31 } 31 32 } … … 35 36 for (int x=0; x<width; x++) { 36 37 delete (*vctMap)[x]; 37 delete (*vct Objects)[x];38 delete (*vctStructures)[x]; 38 39 } 39 40 40 41 delete vctMap; 42 delete vctStructures; 41 43 delete vctObjects; 42 44 } … … 49 51 void WorldMap::setElement(int x, int y, TerrainType t) 50 52 { 51 cout << "getting element" << endl;52 53 (*(*vctMap)[x])[y] = t; 53 54 } 54 55 55 WorldMap::ObjectType WorldMap::getObject(int x, int y) 56 { 57 return (*(*vctObjects)[x])[y]; 58 } 59 60 void WorldMap::setObject(int x, int y, ObjectType t) 61 { 62 cout << "getting object" << endl; 63 (*(*vctObjects)[x])[y] = t; 56 WorldMap::StructureType WorldMap::getStructure(int x, int y) 57 { 58 return (*(*vctStructures)[x])[y]; 59 } 60 61 void WorldMap::setStructure(int x, int y, StructureType t) 62 { 63 (*(*vctStructures)[x])[y] = t; 64 } 65 66 vector<WorldMap::Object> WorldMap::getObjects(int x, int y) { 67 vector<WorldMap::Object> vctObjectsInRegion; 68 69 return vctObjectsInRegion; 70 } 71 72 void WorldMap::addObject(int x, int y, WorldMap::ObjectType t) { 73 WorldMap::Object o(t, x, y); 74 75 vctObjects->push_back(o); 64 76 } 65 77 … … 77 89 m->setElement(x, y, TERRAIN_GRASS); 78 90 79 m->set Object(x, y, OBJECT_NONE);91 m->setStructure(x, y, STRUCTURE_NONE); 80 92 } 81 93 } … … 158 170 159 171 int x, y, type; 160 ObjectType object;172 StructureType structure; 161 173 162 174 getline(iss, token, ','); … … 174 186 switch(type) { 175 187 case 0: 176 object = OBJECT_NONE;188 structure = STRUCTURE_NONE; 177 189 break; 178 190 case 1: 179 object = OBJECT_BLUE_FLAG;191 structure = STRUCTURE_BLUE_FLAG; 180 192 break; 181 193 case 2: 182 object = OBJECT_RED_FLAG;194 structure = STRUCTURE_RED_FLAG; 183 195 break; 184 196 } 185 197 186 m->set Object(x, y, object);198 m->setStructure(x, y, structure); 187 199 } 188 200 } … … 197 209 return m; 198 210 } 211 212 213 /*** Functions for Object ***/ 214 215 WorldMap::Object::Object(ObjectType type, POSITION pos) { 216 this->type = type; 217 this->pos = pos; 218 } 219 220 WorldMap::Object::Object(ObjectType type, int x, int y) { 221 this->type = type; 222 this->pos.x = x; 223 this->pos.y = y; 224 } 225 226 WorldMap::Object::~Object() { 227 }
Note:
See TracChangeset
for help on using the changeset viewer.