From 47dd27c42f375b65ee53f8b1e8c1b25327315a92 Mon Sep 17 00:00:00 2001 From: JAROWMR Date: Sun, 10 Nov 2024 21:38:58 +0100 Subject: box-box collision --- src/crepe/api/BoxCollider.cpp | 5 ++--- src/crepe/api/BoxCollider.h | 2 +- src/crepe/api/CMakeLists.txt | 4 ++++ src/crepe/api/CircleCollider.cpp | 2 -- src/crepe/api/CircleCollider.h | 1 + src/crepe/api/Rigidbody.h | 2 ++ 6 files changed, 10 insertions(+), 6 deletions(-) (limited to 'src/crepe/api') diff --git a/src/crepe/api/BoxCollider.cpp b/src/crepe/api/BoxCollider.cpp index c3cb60c..eafbdb2 100644 --- a/src/crepe/api/BoxCollider.cpp +++ b/src/crepe/api/BoxCollider.cpp @@ -1,8 +1,7 @@ -#pragma once - #include "BoxCollider.h" +#include "../Collider.h" using namespace crepe; -BoxCollider::BoxCollider(game_object_id_t game_object_id,Vector2 offset, int width, int height) : Collider(game_object_id,offset), width(width), height(height) {} +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 index 2461636..357c979 100644 --- a/src/crepe/api/BoxCollider.h +++ b/src/crepe/api/BoxCollider.h @@ -7,7 +7,7 @@ namespace crepe { class BoxCollider : public Collider { public: - BoxCollider(game_object_id_t game_object_id,Vector2 offset, int width, int height); + BoxCollider(game_object_id_t game_object_id,Vector2 offset, double width, double height); double width; double height; }; diff --git a/src/crepe/api/CMakeLists.txt b/src/crepe/api/CMakeLists.txt index 87cbb09..6915074 100644 --- a/src/crepe/api/CMakeLists.txt +++ b/src/crepe/api/CMakeLists.txt @@ -18,6 +18,8 @@ target_sources(crepe PUBLIC Vector2.cpp Camera.cpp Animator.cpp + BoxCollider.cpp + CircleCollider.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -42,4 +44,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES SceneManager.hpp Camera.h Animator.h + BoxCollider.h + CircleCollider.h ) diff --git a/src/crepe/api/CircleCollider.cpp b/src/crepe/api/CircleCollider.cpp index 9365793..04a4995 100644 --- a/src/crepe/api/CircleCollider.cpp +++ b/src/crepe/api/CircleCollider.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "CircleCollider.h" using namespace crepe; diff --git a/src/crepe/api/CircleCollider.h b/src/crepe/api/CircleCollider.h index 3a66355..29a9c1e 100644 --- a/src/crepe/api/CircleCollider.h +++ b/src/crepe/api/CircleCollider.h @@ -1,6 +1,7 @@ #pragma once #include "Vector2.h" + #include "../Collider.h" 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: -- cgit v1.2.3