summary refs log tree commit diff stats
path: root/src/editor.h
blob: dbf50c0cc6283770be513e35420b4fd79585e8e5 (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
53
#ifndef EDITOR_H_8BB54FE3
#define EDITOR_H_8BB54FE3

#include "state.h"
#include "vector.h"
#include "level.h"
#include "input.h"
#include "input_lag.h"

class Editor : public State {
public:

  Editor(SDL_Renderer* ren) : level_(ren)
  {
    surface_ptr bgSurf(IMG_Load("../res/editor_bg.png"));

    if (!bgSurf)
    {
      throw img_error();
    }

    background_.reset(SDL_CreateTextureFromSurface(ren, bgSurf.get()));
    bgSize_ = { bgSurf->w, bgSurf->h };
  }

  void tick(
    double dt,
    const Uint8* keystate) override;

  void render(SDL_Renderer* ren) override;

private:

  Level level_;

  texture_ptr background_;
  vec2i bgSize_;

  texture_ptr renderedMap_;

  bool mapFocus_ = true;
  vec2s cursor_;

  size_t selectedTile_ = 0;

  Input input_;
  InputLag inputLag_;

  Layer layer_ = Layer::map;

};

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