aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api/Event.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-20 22:33:14 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-20 22:33:14 +0100
commit48f69cedaf16038d980071d43d32e22caae44c17 (patch)
treed52db1e10dc82eb02c7d22dbe3fa8648c457c2ce /src/crepe/api/Event.h
parent6808307cf65a4b686621f08a58effecc0a9c6bb8 (diff)
parentda379a58033c0ef3c9c854326a3fca25d6e54319 (diff)
merge `loek/scripts` into `loek/collision-system`
Diffstat (limited to 'src/crepe/api/Event.h')
-rw-r--r--src/crepe/api/Event.h78
1 files changed, 67 insertions, 11 deletions
diff --git a/src/crepe/api/Event.h b/src/crepe/api/Event.h
index bd6a541..9923a05 100644
--- a/src/crepe/api/Event.h
+++ b/src/crepe/api/Event.h
@@ -1,59 +1,115 @@
+// TODO discussing the location of these events
#pragma once
-#include "KeyCodes.h"
-#include <iostream>
+
#include <string>
-#include <typeindex>
-#include "system/CollisionSystem.h"
-class Event {
-public:
-};
+#include "../system/CollisionSystem.h"
+
+#include "KeyCodes.h"
+/**
+ * \brief Base class for all event types in the system.
+ */
+class Event {};
+
+/**
+ * \brief Event triggered when a key is pressed.
+ */
class KeyPressEvent : public Event {
public:
- int repeat = 0;
+ //! false if first time press, true if key is repeated
+ bool repeat = false;
+
+ //! The key that was pressed.
Keycode key = Keycode::NONE;
};
+/**
+ * \brief Event triggered when a key is released.
+ */
class KeyReleaseEvent : public Event {
public:
+ //! The key that was released.
Keycode key = Keycode::NONE;
};
+/**
+ * \brief Event triggered when a mouse button is pressed.
+ */
class MousePressEvent : public Event {
public:
+ //! X-coordinate of the mouse position at the time of the event.
int mouse_x = 0;
+
+ //! Y-coordinate of the mouse position at the time of the event.
int mouse_y = 0;
+
+ //! The mouse button that was pressed.
MouseButton button = MouseButton::NONE;
};
+/**
+ * \brief Event triggered when a mouse button is clicked (press and release).
+ */
class MouseClickEvent : public Event {
public:
+ //! X-coordinate of the mouse position at the time of the event.
int mouse_x = 0;
+
+ //! Y-coordinate of the mouse position at the time of the event.
int mouse_y = 0;
+
+ //! The mouse button that was clicked.
MouseButton button = MouseButton::NONE;
};
+
+/**
+ * \brief Event triggered when a mouse button is released.
+ */
class MouseReleaseEvent : public Event {
public:
+ //! X-coordinate of the mouse position at the time of the event.
int mouse_x = 0;
+
+ //! Y-coordinate of the mouse position at the time of the event.
int mouse_y = 0;
+
+ //! The mouse button that was released.
MouseButton button = MouseButton::NONE;
};
+
+/**
+ * \brief Event triggered when the mouse is moved.
+ */
class MouseMoveEvent : public Event {
public:
+ //! X-coordinate of the mouse position at the time of the event.
int mouse_x = 0;
+
+ //! Y-coordinate of the mouse position at the time of the event.
int mouse_y = 0;
};
+
+/**
+ * \brief Event triggered during a collision between objects.
+ */
class CollisionEvent : public Event {
public:
crepe::CollisionSystem::CollisionInfo info;
CollisionEvent(const crepe::CollisionSystem::CollisionInfo& collisionInfo)
: info(collisionInfo) {}
};
+
+/**
+ * \brief Event triggered when text is submitted, e.g., from a text input.
+ */
class TextSubmitEvent : public Event {
public:
+ //! The submitted text.
std::string text = "";
};
-class ShutDownEvent : public Event {
-public:
-};
+
+/**
+ * \brief Event triggered to indicate the application is shutting down.
+ */
+class ShutDownEvent : public Event {};