diff options
Diffstat (limited to 'src/map.h')
| -rw-r--r-- | src/map.h | 42 |
1 files changed, 42 insertions, 0 deletions
| diff --git a/src/map.h b/src/map.h new file mode 100644 index 0000000..7986e0d --- /dev/null +++ b/src/map.h | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | #include <list> | ||
| 2 | #include <vector> | ||
| 3 | #include "mob.h" | ||
| 4 | #include "renderer.h" | ||
| 5 | |||
| 6 | using namespace::std; | ||
| 7 | |||
| 8 | const int TILE_WIDTH = 8; | ||
| 9 | const int TILE_HEIGHT = 8; | ||
| 10 | const int GAME_WIDTH = 320; | ||
| 11 | const int GAME_HEIGHT = 200; | ||
| 12 | const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; | ||
| 13 | const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT; | ||
| 14 | |||
| 15 | enum direction_t { | ||
| 16 | up, left, down, right | ||
| 17 | }; | ||
| 18 | |||
| 19 | typedef struct { | ||
| 20 | int axis; | ||
| 21 | int lower; | ||
| 22 | int upper; | ||
| 23 | int type; | ||
| 24 | } collision_t; | ||
| 25 | |||
| 26 | class Map { | ||
| 27 | public: | ||
| 28 | Map(); | ||
| 29 | ~Map(); | ||
| 30 | void render(Texture* buffer); | ||
| 31 | void check_collisions(mob_t* mob, int x_next, int y_next); | ||
| 32 | |||
| 33 | private: | ||
| 34 | void add_collision(int axis, int lower, int upper, direction_t dir, int type); | ||
| 35 | |||
| 36 | list<collision_t> left_collisions; | ||
| 37 | list<collision_t> right_collisions; | ||
| 38 | list<collision_t> up_collisions; | ||
| 39 | list<collision_t> down_collisions; | ||
| 40 | |||
| 41 | Texture* bg; | ||
| 42 | }; \ No newline at end of file | ||
