summaryrefslogtreecommitdiff
path: root/src/Level.h
blob: 7791ab6a0ea031bdc3ffc79e3faeeefdc11cc5a6 (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
46
47
#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 playerCanStep(int dx, int dy);

  int getEnemyIndex(int id);

  bool enemyCanStep(Pos pos, 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