summary refs log tree commit diff stats
path: root/src/level.h
blob: 3d6fb878c903f5e05abd3b95cdce5b1785374c0a (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
43
44
45
46
47
48
49
50
51
52
#ifndef LEVEL_H_678CFCCF
#define LEVEL_H_678CFCCF

#include "consts.h"
#include "tileset.h"

class Level {
public:

  Level()
  {
    size_ = LEVEL_SIZE;

    tiles_.resize(size_.w() * size_.h());

    for (size_t y = 0; y < size_.h(); y++)
    {
      for (size_t x = 0; x < size_.w(); x++)
      {
        tiles_[x+y*size_.w()] = rand() % 10;
      }
    }
  }

  const vec2s& getSize() const
  {
    return size_;
  }

  size_t at(vec2s pos) const
  {
    return at(pos.x(), pos.y());
  }

  size_t at(size_t x, size_t y) const
  {
    return tiles_.at(x + size_.w() * y);
  }

  const Tileset& getTileset() const
  {
    return tileset_;
  }

private:

  vec2s size_;
  std::vector<size_t> tiles_;
  Tileset tileset_;
};

#endif /* end of include guard: LEVEL_H_678CFCCF */