summary refs log tree commit diff stats
path: root/src/mapview.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-02-17 13:28:50 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-02-17 13:28:50 -0500
commit6b99c7aee539e35b8e67520f36adeca9007641cb (patch)
tree7e265900e63512889109048047ee6a1b103c4339 /src/mapview.h
parent783b308990e7c4ef0837a102a138778f73e4d2b7 (diff)
downloadtherapy-6b99c7aee539e35b8e67520f36adeca9007641cb.tar.gz
therapy-6b99c7aee539e35b8e67520f36adeca9007641cb.tar.bz2
therapy-6b99c7aee539e35b8e67520f36adeca9007641cb.zip
Refactored map loader and added a second map
Also tweaked the font for apostrophe, p, and q
Diffstat (limited to 'src/mapview.h')
-rw-r--r--src/mapview.h58
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
9using namespace::std;
10
11const int TILE_WIDTH = 8;
12const int TILE_HEIGHT = 8;
13const int GAME_WIDTH = 320;
14const int GAME_HEIGHT = 200;
15const int MAP_WIDTH = GAME_WIDTH/TILE_WIDTH;
16const int MAP_HEIGHT = GAME_HEIGHT/TILE_HEIGHT;
17
18const int FRAMES_PER_SECOND = 60;
19
20enum direction_t {
21 up, left, down, right
22};
23
24typedef struct {
25 int axis;
26 int lower;
27 int upper;
28 int type;
29} collision_t;
30
31class 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