+/**
+ * @file window.hpp
+ * Provides a system for handling the game's window.
+ */
+
#ifndef WINDOW_HPP_
#define WINDOW_HPP_
#include <events.hpp>
+/**
+ * @class WindowSystem
+ * Contains everything needed to create and update a window, using SDL.
+ * Also handles window resizing (WIP) and screenshots (WIP).
+ */
class WindowSystem : public entityx::System<WindowSystem>, public entityx::Receiver<WindowSystem> {
private:
+
+ /**
+ * SDL's object for the window.
+ */
SDL_Window *window;
+
+ /**
+ * An OpenGL context, created when OpenGL is set up for use.
+ */
SDL_GLContext glContext;
public:
position.x += direction.x * dt;
position.y += direction.y * dt;
- if (entity.has_component<Sprite>()) {
- auto& fl = entity.component<Sprite>()->faceLeft;
- if (direction.x != 0)
- fl = (direction.x < 0);
- }
+ if (entity.has_component<Dialog>() && entity.component<Dialog>()->talking) {
+ direction.x = 0;
+ } else {
+ if (entity.has_component<Sprite>()) {
+ auto& fl = entity.component<Sprite>()->faceLeft;
+ if (direction.x != 0)
+ fl = (direction.x < 0);
+ }
- if (entity.has_component<Wander>()) {
- auto& countdown = entity.component<Wander>()->countdown;
+ if (entity.has_component<Wander>()) {
+ auto& countdown = entity.component<Wander>()->countdown;
- if (countdown > 0) {
- countdown--;
- } else {
- countdown = 5000 + randGet() % 10 * 100;
- direction.x = (randGet() % 3 - 1) * 0.02f;
+ if (countdown > 0) {
+ countdown--;
+ } else {
+ countdown = 5000 + randGet() % 10 * 100;
+ direction.x = (randGet() % 3 - 1) * 0.02f;
+ }
}
}
});
auto exml = game::engine.getSystem<WorldSystem>()->getXML()->FirstChildElement("Dialog");
int newIndex;
+ if (e.has_component<Direction>())
+ d.talking = true;
+
if (d.index == 9999) {
ui::dialogBox(name.name, "", false, randomDialog[d.rindex % randomDialog.size()]);
ui::waitForDialog();
game::briceUpdate();
}
-
auto cxml = exml->FirstChildElement("content");
const char *content;
if (cxml == nullptr) {
if (exml->QueryIntAttribute("nextid", &newIndex) == XML_NO_ERROR)
d.index = newIndex;
}
+
+ d.talking = false;
}).detach();
}