]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
Scaling textures (start)
authordrumsetmonkey <abelleisle@roadrunner.com>
Wed, 23 Nov 2016 02:25:34 +0000 (21:25 -0500)
committerdrumsetmonkey <abelleisle@roadrunner.com>
Wed, 23 Nov 2016 02:25:34 +0000 (21:25 -0500)
15 files changed:
assets/NPC.png
assets/cat.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/ui.hpp
include/window.hpp
src/components.cpp
src/ui.cpp
src/window.cpp
src/world.cpp

index 8381988e0983e28356719fa574582dd00cf0f3f2..801ceb0649cc0851b4a5ad6f5e72be6ddb85bc5b 100644 (file)
Binary files a/assets/NPC.png and b/assets/NPC.png differ
index a5a09ce8951b9e3a506b20f0d8b826d47f1bae5f..0fb049bc081e8a04aa667718893bfd06dab4c0a3 100644 (file)
Binary files a/assets/cat.png and b/assets/cat.png differ
index 872157137e5c6d8f1c5a44120f6d92b1f4cd62f2..f7e2bb9989e2cf29f8d152d125f663314190eed8 100644 (file)
Binary files a/assets/style/classic/bg/bgFarMountain.png and b/assets/style/classic/bg/bgFarMountain.png differ
index 1bb1ffc07e64a8cb24ba236c820df146b4bbb8c0..d1c621ae2cb406ac9dbdacba499a3ce29e0c77a4 100644 (file)
Binary files a/assets/style/classic/bg/forestTileBack.png and b/assets/style/classic/bg/forestTileBack.png differ
index c2716a5ea1d18fcbaf4d45bb3cf40d63f7331276..db2fe8ba4b8dcd43d41ebfc0730e8b467764ad62 100644 (file)
Binary files a/assets/style/classic/bg/forestTileFar.png and b/assets/style/classic/bg/forestTileFar.png differ
index 44b2cfcbf8484eff2b86900b4bf2256a8fb13bff..0dac8e5c138976bcfa32b7a61724ba00f8305d0f 100644 (file)
Binary files a/assets/style/classic/bg/forestTileFront.png and b/assets/style/classic/bg/forestTileFront.png differ
index 5dfd2c8ad231bcc5f6a4f834abc863b858301c88..24b64f7e2817f8a934f381f28250a8af875f77d9 100644 (file)
Binary files a/assets/style/classic/bg/forestTileMid.png and b/assets/style/classic/bg/forestTileMid.png differ
index 54a9a022883f831b90256442a5f5385e807557ed..c88b1bcc6d21d6f1fc350fde7c8fa2e6b82aab80 100644 (file)
Binary files a/assets/style/classic/house1.png and b/assets/style/classic/house1.png differ
index 8a096381d356590b3f58136bbb57950ed62f9755..975855c443cf29e3ffa8e965ba096ca9960accb3 100644 (file)
 
 class World;
 
+//////////////////////////
+/// INPUT EVENTS
+//////////////////////////
+
 struct MouseScrollEvent {
        MouseScrollEvent(int sd = 0)
                : scrollDistance(sd) {}
@@ -41,6 +45,10 @@ struct KeyUpEvent {
     SDL_Keycode keycode;
 };
 
+//////////////////////////
+/// ENGINE EVENTS
+//////////////////////////
+
 struct GameEndEvent {
     GameEndEvent(bool r = true)
         : really(r) {}
@@ -48,6 +56,10 @@ struct GameEndEvent {
     bool really;
 };
 
+//////////////////////////
+/// WORLD EVENTS
+//////////////////////////
+
 struct BGMToggleEvent {
     BGMToggleEvent(std::string f = "", World *w = nullptr)
         : file(f), world(w) {}
@@ -56,6 +68,10 @@ struct BGMToggleEvent {
        World *world;
 };
 
+//////////////////////////
+/// WINDOW EVENTS
+//////////////////////////
+
 struct WindowResizeEvent {
        WindowResizeEvent(int w = 640, int h = 480)
                : x(w), y(h) {}
@@ -64,4 +80,12 @@ struct WindowResizeEvent {
        int y;
 };
 
+struct ScreenshotEvent {
+       ScreenshotEvent(int w = game::SCREEN_HEIGHT, int h = game::SCREEN_WIDTH)
+               : w(w), h(h) {}
+       
+       int w;
+       int h;  
+};
+
 #endif // EVENTS_HPP_
index c7a69b63fd57490d0d1a8c483741c0fac476f9a2..64aa274a18a58ced2c180f52f497f19be2e6c014 100644 (file)
@@ -156,6 +156,11 @@ namespace ui {
        void waitForCover(void);
        void waitForUncover(void);
 
+       /*
+        *  Takes a screenshot of the game
+        */
+       
+       void takeScreenshot(GLubyte *pixels);
 }
 
 #endif // UI_H
index 364ac8fca226cc6f9ca8b1bb1230986c9590a6ab..55cbe1c8b23c33b425402c004adeb0d9493ba053 100644 (file)
@@ -20,6 +20,7 @@ public:
        void configure(entityx::EventManager &ev);
     void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
        void receive(const WindowResizeEvent&); 
+       void receive(const ScreenshotEvent&);
 };
 
 #endif // WINDOW_HPP_
index c7069ce30030863d68831c6d29dd81425fa68647..f216cd22931238f372293ef91654731eb067b31b 100644 (file)
@@ -53,8 +53,8 @@ void RenderSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
                                                                1.0, 0.0};
 
                for (auto &S : sprite.sprite) {
-                       float width = S.first.size.x;
-                       float height = S.first.size.y;
+                       float width = HLINES(S.first.size.x);
+                       float height = HLINES(S.first.size.y);
 
                        vec2 loc = vec2(pos.x + S.first.offset.x, pos.y + S.first.offset.y);
 
index e9738cf785364ff5413836d50b08fe2061ff56c1..922e5be5ae4d302853d851a5c343e17b87cb2b58 100644 (file)
@@ -1337,10 +1337,12 @@ void InputSystem::update(entityx::EntityManager &en, entityx::EventManager &ev,
                                break;
                        case SDLK_F12:
                                // Make the BYTE array, factor of 3 because it's RBG.
-                               static GLubyte* pixels;
+                               /*static GLubyte* pixels;
                                pixels = new GLubyte[ 3 * SCREEN_WIDTH * SCREEN_HEIGHT];
                                glReadPixels(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, GL_RGB, GL_UNSIGNED_BYTE, pixels);
-                               takeScreenshot(pixels);
+                               takeScreenshot(pixels);*/
+
+                               ev.emit<ScreenshotEvent>(game::SCREEN_WIDTH, game::SCREEN_HEIGHT);
 
                                std::cout << "Took screenshot" << std::endl;
                                break;
index 4c73b8ba03762825a3dc592942bb34b28b7ce06e..f878ec31274024e9d1dab48428f754b3177642d2 100644 (file)
@@ -66,6 +66,7 @@ void WindowSystem::die(void)
 void WindowSystem::configure(entityx::EventManager &ev)
 {
     ev.subscribe<WindowResizeEvent>(*this);
+       ev.subscribe<ScreenshotEvent>(*this);
 }
 
 
@@ -78,6 +79,22 @@ void WindowSystem::receive(const WindowResizeEvent &wre)
        SDL_SetWindowSize(window, wre.x, wre.y);
 }      
 
+#include <ui.hpp>
+
+void WindowSystem::receive(const ScreenshotEvent &scr)
+{
+       // Make the BYTE array, factor of 3 because it's RBG.
+       static GLubyte* pixels;
+       pixels = new GLubyte[ 3 * scr.w * scr.h];
+       //glReadPixels(0, 0, scr.w, scr.h, GL_RGB, GL_UNSIGNED_BYTE, pixels);
+       for(int i = 0; i < (3 * scr.w * scr.h); i++) {
+               pixels[i] = 255;
+       }
+
+       ui::takeScreenshot(pixels);
+       std::cout << "Triggered\n";
+}
+
 void WindowSystem::update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt)
 {
     (void)en;
index 8f67d8ba69c1e1618158e3902fe9b9807f53b3cb..02db9cff221ef11be972d1ed073c8e9aa65dd528 100644 (file)
@@ -759,6 +759,8 @@ void WorldSystem::render(void)
 
        bgTex++;
        auto mountainDim = bgTex.getTextureDim();
+       mountainDim.x = HLINES(mountainDim.x);
+       mountainDim.y = HLINES(mountainDim.y);
     auto xcoord = width / 2 * -1 + offset.x * 0.85f;
        for (int i = 0; i <= width / mountainDim.x; i++) {
         bg_items.emplace_back(mountainDim.x * i       + xcoord, GROUND_HEIGHT_MINIMUM,                                  8.0f);
@@ -786,6 +788,8 @@ void WorldSystem::render(void)
        for (unsigned int i = 0; i < 4; i++) {
                bgTex++;
                auto dim = bgTex.getTextureDim();
+               dim.x = HLINES(dim.x);
+               dim.y = HLINES(dim.y);
                auto xcoord = offset.x * bgDraw[i][2];
 
                bg_items.clear();