summaryrefslogtreecommitdiff
path: root/src/Level.h
blob: 1607f0c0521170538933df3059d223cd9c5d2a61 (plain)
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
43
44
45
#ifndef DNG_LEVEL_H
#define DNG_LEVEL_H

static const char PLAYER_TKN = 'p';
static const char WALL_TKN = 'w';
static const char EMPTY_TKN = '0';
static const char TREASURE_TKN = 't';
static const char ENEMY_TKN = 'e';
static const char BLANK_SPACE = '\0';
static const char WALL_SPACE = '#';

#include <memory>
#include <vector>

struct Pos
{
  int id;
  int x;
  int y;
} typedef Coord;

class Level
{

public:
  void loadLevelFromFile(const char* filePath);

  bool isEmpty(int x, int y);

  bool canStep(int dx, int dy);

  void print();

  int nextId();

  std::vector<std::vector<char>> map;
  Pos player;
  std::vector<Pos> enemyPositions;
  std::vector<Pos> treasurePositions;

private:
  int idCounter = 1; // defaults at 1 (player always 0)
};

#endif // DNG_LEVEL_H