aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2016-11-22 21:25:34 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2016-11-22 21:25:34 -0500
commit05dd30a5158184fea83d93f53e8100aecaebb74a (patch)
tree9bf7a49b1aeb7d9b41d0c2fffbddc7f91243bf32
parente51b9ee1e0f9b8aeef98b8875f66260db0e7b502 (diff)
Scaling textures (start)
-rw-r--r--assets/NPC.pngbin624 -> 473 bytes
-rw-r--r--assets/cat.pngbin557 -> 402 bytes
-rw-r--r--assets/style/classic/bg/bgFarMountain.pngbin148956 -> 36511 bytes
-rw-r--r--assets/style/classic/bg/forestTileBack.pngbin33765 -> 11182 bytes
-rw-r--r--assets/style/classic/bg/forestTileFar.pngbin36779 -> 12789 bytes
-rw-r--r--assets/style/classic/bg/forestTileFront.pngbin28679 -> 9099 bytes
-rw-r--r--assets/style/classic/bg/forestTileMid.pngbin32169 -> 11273 bytes
-rw-r--r--assets/style/classic/house1.pngbin2455 -> 1434 bytes
-rw-r--r--include/events.hpp24
-rw-r--r--include/ui.hpp5
-rw-r--r--include/window.hpp1
-rw-r--r--src/components.cpp4
-rw-r--r--src/ui.cpp6
-rw-r--r--src/window.cpp17
-rw-r--r--src/world.cpp4
15 files changed, 57 insertions, 4 deletions
diff --git a/assets/NPC.png b/assets/NPC.png
index 8381988..801ceb0 100644
--- a/assets/NPC.png
+++ b/assets/NPC.png
Binary files differ
diff --git a/assets/cat.png b/assets/cat.png
index a5a09ce..0fb049b 100644
--- a/assets/cat.png
+++ b/assets/cat.png
Binary files differ
diff --git a/assets/style/classic/bg/bgFarMountain.png b/assets/style/classic/bg/bgFarMountain.png
index 8721571..f7e2bb9 100644
--- a/assets/style/classic/bg/bgFarMountain.png
+++ b/assets/style/classic/bg/bgFarMountain.png
Binary files differ
diff --git a/assets/style/classic/bg/forestTileBack.png b/assets/style/classic/bg/forestTileBack.png
index 1bb1ffc..d1c621a 100644
--- a/assets/style/classic/bg/forestTileBack.png
+++ b/assets/style/classic/bg/forestTileBack.png
Binary files differ
diff --git a/assets/style/classic/bg/forestTileFar.png b/assets/style/classic/bg/forestTileFar.png
index c2716a5..db2fe8b 100644
--- a/assets/style/classic/bg/forestTileFar.png
+++ b/assets/style/classic/bg/forestTileFar.png
Binary files differ
diff --git a/assets/style/classic/bg/forestTileFront.png b/assets/style/classic/bg/forestTileFront.png
index 44b2cfc..0dac8e5 100644
--- a/assets/style/classic/bg/forestTileFront.png
+++ b/assets/style/classic/bg/forestTileFront.png
Binary files differ
diff --git a/assets/style/classic/bg/forestTileMid.png b/assets/style/classic/bg/forestTileMid.png
index 5dfd2c8..24b64f7 100644
--- a/assets/style/classic/bg/forestTileMid.png
+++ b/assets/style/classic/bg/forestTileMid.png
Binary files differ
diff --git a/assets/style/classic/house1.png b/assets/style/classic/house1.png
index 54a9a02..c88b1bc 100644
--- a/assets/style/classic/house1.png
+++ b/assets/style/classic/house1.png
Binary files differ
diff --git a/include/events.hpp b/include/events.hpp
index 8a09638..975855c 100644
--- a/include/events.hpp
+++ b/include/events.hpp
@@ -12,6 +12,10 @@
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_
diff --git a/include/ui.hpp b/include/ui.hpp
index c7a69b6..64aa274 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -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
diff --git a/include/window.hpp b/include/window.hpp
index 364ac8f..55cbe1c 100644
--- a/include/window.hpp
+++ b/include/window.hpp
@@ -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_
diff --git a/src/components.cpp b/src/components.cpp
index c7069ce..f216cd2 100644
--- a/src/components.cpp
+++ b/src/components.cpp
@@ -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);
diff --git a/src/ui.cpp b/src/ui.cpp
index e9738cf..922e5be 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -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;
diff --git a/src/window.cpp b/src/window.cpp
index 4c73b8b..f878ec3 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -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;
diff --git a/src/world.cpp b/src/world.cpp
index 8f67d8b..02db9cf 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -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();