summary refs log tree commit diff stats
path: root/src/map.h
blob: 7986e0d73cf2a22368f5f1f752fcf22ef644bddc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <list>
#include <vector>
#include "mob.h"
#include "renderer.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;

enum direction_t {
  up, left, down, right
};

typedef struct {
  int axis;
  int lower;
  int upper;
  int type;
} collision_t;

class Map {
public:
  Map();
  ~Map();
  void render(Texture* buffer);
  void check_collisions(mob_t* mob, int x_next, int y_next);
  
private:
  void add_collision(int axis, int lower, int upper, direction_t dir, int type);
  
  list<collision_t> left_collisions;
  list<collision_t> right_collisions;
  list<collision_t> up_collisions;
  list<collision_t> down_collisions;
  
  Texture* bg;
};