aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe/api')
-rw-r--r--src/crepe/api/BoxCollider.cpp7
-rw-r--r--src/crepe/api/BoxCollider.h15
-rw-r--r--src/crepe/api/CMakeLists.txt10
-rw-r--r--src/crepe/api/CircleCollider.cpp6
-rw-r--r--src/crepe/api/CircleCollider.h8
-rw-r--r--src/crepe/api/Rigidbody.h2
-rw-r--r--src/crepe/api/Vector2.cpp4
-rw-r--r--src/crepe/api/Vector2.h3
8 files changed, 55 insertions, 0 deletions
diff --git a/src/crepe/api/BoxCollider.cpp b/src/crepe/api/BoxCollider.cpp
new file mode 100644
index 0000000..eafbdb2
--- /dev/null
+++ b/src/crepe/api/BoxCollider.cpp
@@ -0,0 +1,7 @@
+#include "BoxCollider.h"
+#include "../Collider.h"
+
+using namespace crepe;
+
+
+BoxCollider::BoxCollider(game_object_id_t game_object_id,Vector2 offset, double width, double height) : Collider(game_object_id,offset), width(width), height(height) {}
diff --git a/src/crepe/api/BoxCollider.h b/src/crepe/api/BoxCollider.h
new file mode 100644
index 0000000..357c979
--- /dev/null
+++ b/src/crepe/api/BoxCollider.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include "Vector2.h"
+#include "../Collider.h"
+
+namespace crepe {
+
+class BoxCollider : public Collider {
+public:
+ BoxCollider(game_object_id_t game_object_id,Vector2 offset, double width, double height);
+ double width;
+ double height;
+};
+
+} // namespace crepe
diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt
index 85696c4..de1b4b3 100644
--- a/src/crepe/api/CMakeLists.txt
+++ b/src/crepe/api/CMakeLists.txt
@@ -18,8 +18,13 @@ target_sources(crepe PUBLIC
Vector2.cpp
Camera.cpp
Animator.cpp
+<<<<<<< HEAD
+ BoxCollider.cpp
+ CircleCollider.cpp
+=======
LoopManager.cpp
LoopTimer.cpp
+>>>>>>> be1e97bc7a494963ab1567492fafcda99e36f683
)
target_sources(crepe PUBLIC FILE_SET HEADERS FILES
@@ -44,6 +49,11 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES
SceneManager.hpp
Camera.h
Animator.h
+<<<<<<< HEAD
+ BoxCollider.h
+ CircleCollider.h
+=======
LoopManager.h
LoopTimer.h
+>>>>>>> be1e97bc7a494963ab1567492fafcda99e36f683
)
diff --git a/src/crepe/api/CircleCollider.cpp b/src/crepe/api/CircleCollider.cpp
new file mode 100644
index 0000000..04a4995
--- /dev/null
+++ b/src/crepe/api/CircleCollider.cpp
@@ -0,0 +1,6 @@
+#include "CircleCollider.h"
+
+using namespace crepe;
+
+
+CircleCollider::CircleCollider(game_object_id_t game_object_id,Vector2 offset, int radius) : Collider(game_object_id,offset), radius(radius) {}
diff --git a/src/crepe/api/CircleCollider.h b/src/crepe/api/CircleCollider.h
index e77a592..e4f0452 100644
--- a/src/crepe/api/CircleCollider.h
+++ b/src/crepe/api/CircleCollider.h
@@ -1,14 +1,22 @@
#pragma once
+
+#include "Vector2.h"
+
#include "../Collider.h"
namespace crepe {
class CircleCollider : public Collider {
public:
+<<<<<<< HEAD
+ CircleCollider(game_object_id_t game_object_id,Vector2 offset, int radius);
+ double radius;
+=======
CircleCollider(game_object_id_t game_object_id, int radius)
: Collider(game_object_id),
radius(radius) {}
int radius;
+>>>>>>> be1e97bc7a494963ab1567492fafcda99e36f683
};
} // namespace crepe
diff --git a/src/crepe/api/Rigidbody.h b/src/crepe/api/Rigidbody.h
index 68481f4..b9edec2 100644
--- a/src/crepe/api/Rigidbody.h
+++ b/src/crepe/api/Rigidbody.h
@@ -75,6 +75,8 @@ public:
bool use_gravity = true;
//! if object bounces
bool bounce = false;
+ //! offset of all colliders
+ Vector2 offset;
};
public:
diff --git a/src/crepe/api/Vector2.cpp b/src/crepe/api/Vector2.cpp
index 09b3fa3..947c49e 100644
--- a/src/crepe/api/Vector2.cpp
+++ b/src/crepe/api/Vector2.cpp
@@ -54,4 +54,8 @@ bool Vector2::operator!=(const Vector2 & other) const {
return !(*this == other);
}
+double Vector2::dot(const Vector2& other) const {
+ return this->x * other.x + this->y * other.y;
+}
+
} // namespace crepe
diff --git a/src/crepe/api/Vector2.h b/src/crepe/api/Vector2.h
index 5a57484..90d9d57 100644
--- a/src/crepe/api/Vector2.h
+++ b/src/crepe/api/Vector2.h
@@ -42,6 +42,9 @@ public:
//! Checks if this vector is not equal to another vector.
bool operator!=(const Vector2 & other) const;
+
+ //!
+ double dot(const Vector2& other) const;
};
} // namespace crepe