class World;
+//////////////////////////
+/// INPUT EVENTS
+//////////////////////////
+
struct MouseScrollEvent {
MouseScrollEvent(int sd = 0)
: scrollDistance(sd) {}
SDL_Keycode keycode;
};
+//////////////////////////
+/// ENGINE EVENTS
+//////////////////////////
+
struct GameEndEvent {
GameEndEvent(bool r = true)
: really(r) {}
bool really;
};
+//////////////////////////
+/// WORLD EVENTS
+//////////////////////////
+
struct BGMToggleEvent {
BGMToggleEvent(std::string f = "", World *w = nullptr)
: file(f), world(w) {}
World *world;
};
+//////////////////////////
+/// WINDOW EVENTS
+//////////////////////////
+
struct WindowResizeEvent {
WindowResizeEvent(int w = 640, int h = 480)
: x(w), y(h) {}
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_
void waitForCover(void);
void waitForUncover(void);
+ /*
+ * Takes a screenshot of the game
+ */
+
+ void takeScreenshot(GLubyte *pixels);
}
#endif // UI_H
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_
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);
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;
void WindowSystem::configure(entityx::EventManager &ev)
{
ev.subscribe<WindowResizeEvent>(*this);
+ ev.subscribe<ScreenshotEvent>(*this);
}
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;
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);
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();