diff options
author | Andy <drumsetmonkey@gmail.com> | 2016-10-26 07:32:25 -0400 |
---|---|---|
committer | Andy <drumsetmonkey@gmail.com> | 2016-10-26 07:32:25 -0400 |
commit | 8eb1625aea5ccaa07414e699e784440a94277ab0 (patch) | |
tree | b09234eef1f5524c7711096fe61953500d6d5925 | |
parent | d7884127950260dd0f1b24aee0bfe64d847f990c (diff) |
Scaling work
-rw-r--r-- | assets/NPC.png | bin | 473 -> 624 bytes | |||
-rw-r--r-- | assets/style/classic/bg/bgFarMountain.png | bin | 151687 -> 148956 bytes | |||
-rw-r--r-- | assets/style/classic/bg/forestTileBack.png | bin | 20973 -> 33765 bytes | |||
-rw-r--r-- | assets/style/classic/bg/forestTileFar.png | bin | 23788 -> 36779 bytes | |||
-rw-r--r-- | assets/style/classic/bg/forestTileFront.png | bin | 17530 -> 28679 bytes | |||
-rw-r--r-- | assets/style/classic/bg/forestTileMid.png | bin | 19778 -> 32169 bytes | |||
-rw-r--r-- | assets/style/classic/house1.png | bin | 1434 -> 2455 bytes | |||
-rw-r--r-- | include/events.hpp | 8 | ||||
-rw-r--r-- | include/window.hpp | 6 | ||||
-rw-r--r-- | src/engine.cpp | 2 | ||||
-rw-r--r-- | src/ui.cpp | 16 | ||||
-rw-r--r-- | src/window.cpp | 17 |
12 files changed, 45 insertions, 4 deletions
diff --git a/assets/NPC.png b/assets/NPC.png Binary files differindex fdebfa9..8381988 100644 --- a/assets/NPC.png +++ b/assets/NPC.png diff --git a/assets/style/classic/bg/bgFarMountain.png b/assets/style/classic/bg/bgFarMountain.png Binary files differindex 2ec7dae..8721571 100644 --- a/assets/style/classic/bg/bgFarMountain.png +++ b/assets/style/classic/bg/bgFarMountain.png diff --git a/assets/style/classic/bg/forestTileBack.png b/assets/style/classic/bg/forestTileBack.png Binary files differindex c3a7daf..1bb1ffc 100644 --- a/assets/style/classic/bg/forestTileBack.png +++ b/assets/style/classic/bg/forestTileBack.png diff --git a/assets/style/classic/bg/forestTileFar.png b/assets/style/classic/bg/forestTileFar.png Binary files differindex 1302130..c2716a5 100644 --- a/assets/style/classic/bg/forestTileFar.png +++ b/assets/style/classic/bg/forestTileFar.png diff --git a/assets/style/classic/bg/forestTileFront.png b/assets/style/classic/bg/forestTileFront.png Binary files differindex 5b2d250..44b2cfc 100644 --- a/assets/style/classic/bg/forestTileFront.png +++ b/assets/style/classic/bg/forestTileFront.png diff --git a/assets/style/classic/bg/forestTileMid.png b/assets/style/classic/bg/forestTileMid.png Binary files differindex 152af65..5dfd2c8 100644 --- a/assets/style/classic/bg/forestTileMid.png +++ b/assets/style/classic/bg/forestTileMid.png diff --git a/assets/style/classic/house1.png b/assets/style/classic/house1.png Binary files differindex 025b169..54a9a02 100644 --- a/assets/style/classic/house1.png +++ b/assets/style/classic/house1.png diff --git a/include/events.hpp b/include/events.hpp index 7f70c04..5cd8040 100644 --- a/include/events.hpp +++ b/include/events.hpp @@ -47,4 +47,12 @@ struct BGMToggleEvent { World *world; }; +struct WindowResizeEvent { + WindowResizeEvent(int w, int h) + : x(w), y(h) {} + + int x; + int y; +}; + #endif // EVENTS_HPP_ diff --git a/include/window.hpp b/include/window.hpp index d168a54..364ac8f 100644 --- a/include/window.hpp +++ b/include/window.hpp @@ -5,7 +5,9 @@ #include <SDL2/SDL.h> -class WindowSystem : public entityx::System<WindowSystem> { +#include <events.hpp> + +class WindowSystem : public entityx::System<WindowSystem>, public entityx::Receiver<WindowSystem> { private: SDL_Window *window; SDL_GLContext glContext; @@ -15,7 +17,9 @@ public: void die(void); + void configure(entityx::EventManager &ev); void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; + void receive(const WindowResizeEvent&); }; #endif // WINDOW_HPP_ diff --git a/src/engine.cpp b/src/engine.cpp index 90cfb3a..f4d19a2 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -2,9 +2,9 @@ #include <config.hpp> #include <world.hpp> +#include <window.hpp> #include <ui.hpp> #include <inventory.hpp> -#include <window.hpp> #include <components.hpp> #include <player.hpp> @@ -8,11 +8,10 @@ #include <render.hpp> #include <engine.hpp> #include <events.hpp> +#include <window.hpp> extern Menu* currentMenu; -extern SDL_Window *window; - std::array<SDL_Keycode, 6> controlMap = { SDLK_w, SDLK_a, SDLK_d, SDLK_LSHIFT, SDLK_LCTRL, SDLK_e }; @@ -1244,6 +1243,19 @@ void InputSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, case SDL_QUIT: game::endGame(); break; + + // window events - used for resizing and stuff + case SDL_WINDOWEVENT: + switch (e.window.event) { + case SDL_WINDOWEVENT_RESIZED: + std::cout << "Window " << e.window.windowID << " resized to: " << e.window.data1 << ", " << e.window.data2 << std::endl; + auto w = e.window.data1; + auto h = e.window.data2; + ev.emit<WindowResizeEvent>(w,h); + break; + } + break; + // mouse movement - update mouse vector case SDL_MOUSEMOTION: diff --git a/src/window.cpp b/src/window.cpp index e21bf69..69c383c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -2,6 +2,7 @@ #include <config.hpp> +#include <SDL2/SDL_opengl.h> #include <SDL2/SDL_image.h> #include <SDL2/SDL_mixer.h> @@ -61,6 +62,22 @@ void WindowSystem::die(void) SDL_DestroyWindow(window); } + +void WindowSystem::configure(entityx::EventManager &ev) +{ + ev.subscribe<WindowResizeEvent>(*this); +} + + +void WindowSystem::receive(const WindowResizeEvent &wre) +{ + + game::SCREEN_WIDTH = wre.x; + game::SCREEN_HEIGHT = wre.y; + glViewport(0, 0, wre.x, wre.y); + SDL_SetWindowSize(window, wre.x, wre.y); +} + void WindowSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) { (void)en; |