From 6b99c7aee539e35b8e67520f36adeca9007641cb Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 17 Feb 2015 13:28:50 -0500 Subject: Refactored map loader and added a second map Also tweaked the font for apostrophe, p, and q --- src/mapview.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/mapview.h (limited to 'src/mapview.h') 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 @@ +#ifndef MAPVIEW_H +#define MAPVIEW_H + +#include +#include "state.h" +#include "mob.h" +#include "map.h" + +using namespace::std; + +const int TILE_WIDTH = 8; +const int TILE_HEIGHT = 8; +const int GAME_WIDTH = 320; +const int GAME_HEIGHT = 200; +const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH; +const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT; + +const int FRAMES_PER_SECOND = 60; + +enum direction_t { + up, left, down, right +}; + +typedef struct { + int axis; + int lower; + int upper; + int type; +} collision_t; + +class MapView : public State { + public: + MapView(Map* start, int x, int y); + ~MapView(); + void loadMap(Map* m); + void input(int key, int action); + void tick(); + void render(Texture* tex); + + private: + void add_collision(int axis, int lower, int upper, direction_t dir, int type); + void check_collisions(mob_t* mob, int x_next, int y_next); + + list left_collisions; + list right_collisions; + list up_collisions; + list down_collisions; + + Texture* bg = NULL; + + bool holding_left = false; + bool holding_right = false; + mob_t* player; + + Map* curMap; +}; + +#endif -- cgit 1.4.1