diff options
Diffstat (limited to 'src/mapview.h')
| -rw-r--r-- | src/mapview.h | 58 |
1 files changed, 58 insertions, 0 deletions
| diff --git a/src/mapview.h b/src/mapview.h new file mode 100644 index 0000000..70ffb3b --- /dev/null +++ b/src/mapview.h | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | #ifndef MAPVIEW_H | ||
| 2 | #define MAPVIEW_H | ||
| 3 | |||
| 4 | #include <list> | ||
| 5 | #include "state.h" | ||
| 6 | #include "mob.h" | ||
| 7 | #include "map.h" | ||
| 8 | |||
| 9 | using namespace::std; | ||
| 10 | |||
| 11 | const int TILE_WIDTH = 8; | ||
| 12 | const int TILE_HEIGHT = 8; | ||
| 13 | const int GAME_WIDTH = 320; | ||
| 14 | const int GAME_HEIGHT = 200; | ||
| 15 | const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; | ||
| 16 | const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT; | ||
| 17 | |||
| 18 | const int FRAMES_PER_SECOND = 60; | ||
| 19 | |||
| 20 | enum direction_t { | ||
| 21 | up, left, down, right | ||
| 22 | }; | ||
| 23 | |||
| 24 | typedef struct { | ||
| 25 | int axis; | ||
| 26 | int lower; | ||
| 27 | int upper; | ||
| 28 | int type; | ||
| 29 | } collision_t; | ||
| 30 | |||
| 31 | class MapView : public State { | ||
| 32 | public: | ||
| 33 | MapView(Map* start, int x, int y); | ||
| 34 | ~MapView(); | ||
| 35 | void loadMap(Map* m); | ||
| 36 | void input(int key, int action); | ||
| 37 | void tick(); | ||
| 38 | void render(Texture* tex); | ||
| 39 | |||
| 40 | private: | ||
| 41 | void add_collision(int axis, int lower, int upper, direction_t dir, int type); | ||
| 42 | void check_collisions(mob_t* mob, int x_next, int y_next); | ||
| 43 | |||
| 44 | list<collision_t> left_collisions; | ||
| 45 | list<collision_t> right_collisions; | ||
| 46 | list<collision_t> up_collisions; | ||
| 47 | list<collision_t> down_collisions; | ||
| 48 | |||
| 49 | Texture* bg = NULL; | ||
| 50 | |||
| 51 | bool holding_left = false; | ||
| 52 | bool holding_right = false; | ||
| 53 | mob_t* player; | ||
| 54 | |||
| 55 | Map* curMap; | ||
| 56 | }; | ||
| 57 | |||
| 58 | #endif | ||
