source: network-game/common/WorldMap.h@ 787806f

Last change on this file since 787806f was e4c60ba, checked in by dportnoy <dmp1488@…>, 11 years ago

Players can turn in flags they have picked up to their own flag sites

  • Property mode set to 100644
File size: 1.5 KB
Line 
1#ifndef _WORLDMAP_H
2#define _WORLDMAP_H
3
4#include <string>
5
6#include <vector>
7
8#include "Common.h"
9
10using namespace std;
11
12class WorldMap {
13public:
14 enum TerrainType {
15 TERRAIN_NONE,
16 TERRAIN_GRASS,
17 TERRAIN_OCEAN,
18 TERRAIN_ROCK
19 };
20
21 enum StructureType {
22 STRUCTURE_NONE,
23 STRUCTURE_BLUE_FLAG,
24 STRUCTURE_RED_FLAG
25 };
26
27 enum ObjectType {
28 OBJECT_NONE,
29 OBJECT_BLUE_FLAG,
30 OBJECT_RED_FLAG
31 };
32
33 class Object {
34 public:
35 int id;
36 ObjectType type;
37 POSITION pos;
38
39 Object(int id, ObjectType type, int x, int y);
40 Object(int id, ObjectType type, POSITION pos);
41
42 ~Object();
43
44 void serialize(char* buffer);
45 void deserialize(char* buffer);
46 };
47
48 int width, height;
49 vector<vector<TerrainType>*>* vctMap;
50 vector<vector<StructureType>*>* vctStructures;
51 vector<Object>* vctObjects;
52
53 WorldMap(int width, int height);
54
55 ~WorldMap();
56
57 TerrainType getElement(int x, int y);
58 void setElement(int x, int y, TerrainType type);
59
60 StructureType getStructure(int x, int y);
61 void setStructure(int x, int y, StructureType type);
62 POSITION getStructureLocation(StructureType type);
63
64 vector<Object>* getObjects();
65 vector<Object> getObjects(int x, int y);
66
67 void addObject(ObjectType type, int x, int y);
68 void updateObject(int id, WorldMap::ObjectType t, int x, int y);
69 bool removeObject(int id);
70
71 static WorldMap* createDefaultMap();
72 static WorldMap* loadMapFromFile(string filename);
73};
74
75#endif
Note: See TracBrowser for help on using the repository browser.