aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/Button.cpp0
-rw-r--r--src/crepe/api/Button.h17
-rw-r--r--src/crepe/api/Event.h10
-rw-r--r--src/crepe/api/LoopManager.cpp4
-rw-r--r--src/crepe/api/UiObject.h14
5 files changed, 42 insertions, 3 deletions
diff --git a/src/crepe/api/Button.cpp b/src/crepe/api/Button.cpp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/crepe/api/Button.cpp
diff --git a/src/crepe/api/Button.h b/src/crepe/api/Button.h
new file mode 100644
index 0000000..5035729
--- /dev/null
+++ b/src/crepe/api/Button.h
@@ -0,0 +1,17 @@
+#include <functional>
+
+#include "Component.h"
+#include "api/EventHandler.h"
+#include "api/UiObject.h"
+namespace crepe {
+class Button : public UiObject{
+public:
+ ~Button(){};
+ bool interactable = true;
+ bool is_toggle = false;
+ bool is_pressed = false;
+ std::function<void()> on_click;
+public:
+virtual int get_instances_max() const { return 1; }
+};
+}
diff --git a/src/crepe/api/Event.h b/src/crepe/api/Event.h
index b267e3e..bac8701 100644
--- a/src/crepe/api/Event.h
+++ b/src/crepe/api/Event.h
@@ -88,6 +88,10 @@ public:
//! Y-coordinate of the mouse position at the time of the event.
int mouse_y = 0;
+ // Relative movement in x
+ int rel_x;
+ // Relative movement in y
+ int rel_y;
};
/**
@@ -107,6 +111,8 @@ public:
/**
* \brief Event triggered to indicate the application is shutting down.
*/
-class ShutDownEvent : public Event {};
+class ShutDownEvent : public Event {
+public:
+};
-} // namespace crepe
+}
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp
index 7edf4d1..9599943 100644
--- a/src/crepe/api/LoopManager.cpp
+++ b/src/crepe/api/LoopManager.cpp
@@ -6,6 +6,7 @@
#include "../system/PhysicsSystem.h"
#include "../system/RenderSystem.h"
#include "../system/ScriptSystem.h"
+#include "../system/InputSystem.h"
#include "LoopManager.h"
#include "LoopTimer.h"
@@ -20,10 +21,11 @@ LoopManager::LoopManager() {
this->load_system<PhysicsSystem>();
this->load_system<RenderSystem>();
this->load_system<ScriptSystem>();
+ this->load_system<InputSystem>();
}
void LoopManager::process_input() {
- SDLContext::get_instance().handle_events(this->game_running);
+ this->get_system<InputSystem>().update();
}
void LoopManager::start() {
diff --git a/src/crepe/api/UiObject.h b/src/crepe/api/UiObject.h
new file mode 100644
index 0000000..f57f7ef
--- /dev/null
+++ b/src/crepe/api/UiObject.h
@@ -0,0 +1,14 @@
+#include <functional>
+
+#include "Component.h"
+#include "api/EventHandler.h"
+namespace crepe {
+class UiObject : public Component{
+public:
+ ~UiObject(){};
+ int width = 0;
+ int height = 0;
+public:
+virtual int get_instances_max() const { return 1; }
+};
+}