diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-03-10 12:07:40 -0400 | 
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2019-03-10 12:07:40 -0400 | 
| commit | 57fe8f3c4124819b95164547333a33f4c45eac8d (patch) | |
| tree | 99dd89a0c1cf0a8ceaa2ff941549d631950efd11 /src/editor.h | |
| parent | bf34f891c5c09e6c8a42797085860fa80ab53814 (diff) | |
| download | dispatcher-57fe8f3c4124819b95164547333a33f4c45eac8d.tar.gz dispatcher-57fe8f3c4124819b95164547333a33f4c45eac8d.tar.bz2 dispatcher-57fe8f3c4124819b95164547333a33f4c45eac8d.zip | |
Editor now allows tile placement
You can scroll through the three layers (map, track, object) with Z/X. You can swap between focusing on the map and the tileset with TAB. You can place tiles with enter or space. Pretty rudimentary, but it's a start.
Diffstat (limited to 'src/editor.h')
| -rw-r--r-- | src/editor.h | 30 | 
1 files changed, 30 insertions, 0 deletions
| diff --git a/src/editor.h b/src/editor.h index dc908b9..dbf50c0 100644 --- a/src/editor.h +++ b/src/editor.h | |||
| @@ -3,10 +3,26 @@ | |||
| 3 | 3 | ||
| 4 | #include "state.h" | 4 | #include "state.h" | 
| 5 | #include "vector.h" | 5 | #include "vector.h" | 
| 6 | #include "level.h" | ||
| 7 | #include "input.h" | ||
| 8 | #include "input_lag.h" | ||
| 6 | 9 | ||
| 7 | class Editor : public State { | 10 | class Editor : public State { | 
| 8 | public: | 11 | public: | 
| 9 | 12 | ||
| 13 | Editor(SDL_Renderer* ren) : level_(ren) | ||
| 14 | { | ||
| 15 | surface_ptr bgSurf(IMG_Load("../res/editor_bg.png")); | ||
| 16 | |||
| 17 | if (!bgSurf) | ||
| 18 | { | ||
| 19 | throw img_error(); | ||
| 20 | } | ||
| 21 | |||
| 22 | background_.reset(SDL_CreateTextureFromSurface(ren, bgSurf.get())); | ||
| 23 | bgSize_ = { bgSurf->w, bgSurf->h }; | ||
| 24 | } | ||
| 25 | |||
| 10 | void tick( | 26 | void tick( | 
| 11 | double dt, | 27 | double dt, | 
| 12 | const Uint8* keystate) override; | 28 | const Uint8* keystate) override; | 
| @@ -15,9 +31,23 @@ public: | |||
| 15 | 31 | ||
| 16 | private: | 32 | private: | 
| 17 | 33 | ||
| 34 | Level level_; | ||
| 35 | |||
| 18 | texture_ptr background_; | 36 | texture_ptr background_; | 
| 19 | vec2i bgSize_; | 37 | vec2i bgSize_; | 
| 20 | 38 | ||
| 39 | texture_ptr renderedMap_; | ||
| 40 | |||
| 41 | bool mapFocus_ = true; | ||
| 42 | vec2s cursor_; | ||
| 43 | |||
| 44 | size_t selectedTile_ = 0; | ||
| 45 | |||
| 46 | Input input_; | ||
| 47 | InputLag inputLag_; | ||
| 48 | |||
| 49 | Layer layer_ = Layer::map; | ||
| 50 | |||
| 21 | }; | 51 | }; | 
| 22 | 52 | ||
| 23 | #endif /* end of include guard: EDITOR_H_8BB54FE3 */ | 53 | #endif /* end of include guard: EDITOR_H_8BB54FE3 */ | 
