diff options
-rw-r--r-- | res/editor_bg.png | bin | 0 -> 70248 bytes | |||
-rw-r--r-- | res/editor_bg.psd | bin | 0 -> 216402 bytes | |||
-rw-r--r-- | src/editor.cpp | 27 | ||||
-rw-r--r-- | src/editor.h | 6 | ||||
-rw-r--r-- | src/main.cpp | 3 | ||||
-rw-r--r-- | src/vector.h | 1 |
6 files changed, 37 insertions, 0 deletions
diff --git a/res/editor_bg.png b/res/editor_bg.png new file mode 100644 index 0000000..ea86ba6 --- /dev/null +++ b/res/editor_bg.png | |||
Binary files differ | |||
diff --git a/res/editor_bg.psd b/res/editor_bg.psd new file mode 100644 index 0000000..c754ceb --- /dev/null +++ b/res/editor_bg.psd | |||
Binary files differ | |||
diff --git a/src/editor.cpp b/src/editor.cpp index 6e53ac3..92c6b67 100644 --- a/src/editor.cpp +++ b/src/editor.cpp | |||
@@ -1,4 +1,5 @@ | |||
1 | #include "editor.h" | 1 | #include "editor.h" |
2 | #include "consts.h" | ||
2 | 3 | ||
3 | void Editor::tick( | 4 | void Editor::tick( |
4 | double dt, | 5 | double dt, |
@@ -9,5 +10,31 @@ void Editor::tick( | |||
9 | 10 | ||
10 | void Editor::render(SDL_Renderer* ren) | 11 | void Editor::render(SDL_Renderer* ren) |
11 | { | 12 | { |
13 | if (!background_) | ||
14 | { | ||
15 | surface_ptr bgSurf(IMG_Load("../res/editor_bg.png")); | ||
12 | 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 | |||
26 | for (int y = 0; y < WINDOW_SIZE.h() / bgSize_.h(); y++) | ||
27 | { | ||
28 | for (int x = 0; x < WINDOW_SIZE.w() / bgSize_.w(); x++) | ||
29 | { | ||
30 | SDL_Rect rect { | ||
31 | x * bgSize_.w(), | ||
32 | y * bgSize_.h(), | ||
33 | bgSize_.w(), | ||
34 | bgSize_.h() | ||
35 | }; | ||
36 | |||
37 | SDL_RenderCopy(ren, background_.get(), nullptr, &rect); | ||
38 | } | ||
39 | } | ||
13 | } | 40 | } |
diff --git a/src/editor.h b/src/editor.h index aa137ec..dc908b9 100644 --- a/src/editor.h +++ b/src/editor.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define EDITOR_H_8BB54FE3 | 2 | #define EDITOR_H_8BB54FE3 |
3 | 3 | ||
4 | #include "state.h" | 4 | #include "state.h" |
5 | #include "vector.h" | ||
5 | 6 | ||
6 | class Editor : public State { | 7 | class Editor : public State { |
7 | public: | 8 | public: |
@@ -12,6 +13,11 @@ public: | |||
12 | 13 | ||
13 | void render(SDL_Renderer* ren) override; | 14 | void render(SDL_Renderer* ren) override; |
14 | 15 | ||
16 | private: | ||
17 | |||
18 | texture_ptr background_; | ||
19 | vec2i bgSize_; | ||
20 | |||
15 | }; | 21 | }; |
16 | 22 | ||
17 | #endif /* end of include guard: EDITOR_H_8BB54FE3 */ | 23 | #endif /* end of include guard: EDITOR_H_8BB54FE3 */ |
diff --git a/src/main.cpp b/src/main.cpp index 7c65e81..cbac5bb 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
@@ -11,6 +11,9 @@ int main(int argc, char** argv) | |||
11 | std::random_device randomEngine; | 11 | std::random_device randomEngine; |
12 | std::mt19937 rng(randomEngine()); | 12 | std::mt19937 rng(randomEngine()); |
13 | 13 | ||
14 | sdl_wrapper sdl; | ||
15 | img_wrapper img; | ||
16 | |||
14 | window_ptr win( | 17 | window_ptr win( |
15 | SDL_CreateWindow( | 18 | SDL_CreateWindow( |
16 | "dispatcher", | 19 | "dispatcher", |
diff --git a/src/vector.h b/src/vector.h index a94aea0..c207dc8 100644 --- a/src/vector.h +++ b/src/vector.h | |||
@@ -120,5 +120,6 @@ public: | |||
120 | }; | 120 | }; |
121 | 121 | ||
122 | using vec2s = vec2<size_t>; | 122 | using vec2s = vec2<size_t>; |
123 | using vec2i = vec2<int>; | ||
123 | 124 | ||
124 | #endif /* end of include guard: COORDINATES_H_A45D34FB */ | 125 | #endif /* end of include guard: COORDINATES_H_A45D34FB */ |