]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Scaling work
authorAndy <drumsetmonkey@gmail.com>
Wed, 26 Oct 2016 11:32:25 +0000 (07:32 -0400)
committerAndy <drumsetmonkey@gmail.com>
Wed, 26 Oct 2016 11:32:25 +0000 (07:32 -0400)
12 files changed:
assets/NPC.png
assets/style/classic/bg/bgFarMountain.png
assets/style/classic/bg/forestTileBack.png
assets/style/classic/bg/forestTileFar.png
assets/style/classic/bg/forestTileFront.png
assets/style/classic/bg/forestTileMid.png
assets/style/classic/house1.png
include/events.hpp
include/window.hpp
src/engine.cpp
src/ui.cpp
src/window.cpp

index fdebfa93189a744d6271fc43268498fc4017276e..8381988e0983e28356719fa574582dd00cf0f3f2 100644 (file)
Binary files a/assets/NPC.png and b/assets/NPC.png differ
index 2ec7dae746b7022fc7a5634a42e54531228a77bf..872157137e5c6d8f1c5a44120f6d92b1f4cd62f2 100644 (file)
Binary files a/assets/style/classic/bg/bgFarMountain.png and b/assets/style/classic/bg/bgFarMountain.png differ
index c3a7dafdfae997929078b147b9d05415cbad774f..1bb1ffc07e64a8cb24ba236c820df146b4bbb8c0 100644 (file)
Binary files a/assets/style/classic/bg/forestTileBack.png and b/assets/style/classic/bg/forestTileBack.png differ
index 13021305015f31dc4364c4beb389be1271cd3f20..c2716a5ea1d18fcbaf4d45bb3cf40d63f7331276 100644 (file)
Binary files a/assets/style/classic/bg/forestTileFar.png and b/assets/style/classic/bg/forestTileFar.png differ
index 5b2d250342a5f9c5671d22b965a40e91b5a844c2..44b2cfcbf8484eff2b86900b4bf2256a8fb13bff 100644 (file)
Binary files a/assets/style/classic/bg/forestTileFront.png and b/assets/style/classic/bg/forestTileFront.png differ
index 152af65c7b805f24ebcc2a9c4596e0b05444ada9..5dfd2c8ad231bcc5f6a4f834abc863b858301c88 100644 (file)
Binary files a/assets/style/classic/bg/forestTileMid.png and b/assets/style/classic/bg/forestTileMid.png differ
index 025b169a978bc3326633fd54c1c36f352a9ae649..54a9a022883f831b90256442a5f5385e807557ed 100644 (file)
Binary files a/assets/style/classic/house1.png and b/assets/style/classic/house1.png differ
index 7f70c04b04b96b5843de2203e165e227baf7bbed..5cd804091b9817e900d2d8d558f76135501b83b7 100644 (file)
@@ -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_
index d168a5418e2c4fcda735694e48dc68e47cea89fc..364ac8fca226cc6f9ca8b1bb1230986c9590a6ab 100644 (file)
@@ -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_
index 90cfb3ac970cc3cf7b6f189cab0007ab45fa7c5f..f4d19a23f9c5888c2d98b03df5f1e5bcfd2f4459 100644 (file)
@@ -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>
 
index 43dd6cc04b416b3a0f65743a8810d15137f8151b..473126192062b6580d82ecc98554c55365887ebe 100644 (file)
@@ -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:
index e21bf696ee0b139235da5eadda5375007a726db9..69c383cc490f4cf2bc3753a204698d39c8f8b357 100644 (file)
@@ -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;