box collider

This commit is contained in:
2026-04-13 14:03:59 +02:00
parent 0f776347f4
commit dc55af5323
8 changed files with 67 additions and 5 deletions

View File

@@ -1,8 +1,13 @@
#pragma once
#include <object/components/component.hpp>
#include <state/gamestate.hpp>
namespace Game::Object::Components {
struct BoxColliderBounds {
float left, right, top, bottom;
};
class BoxCollider : public Component {
public:
BoxCollider() = default;
@@ -15,6 +20,11 @@ namespace Game::Object::Components {
void start(Object::Entity* thisEntity) override;
void update(float deltaTime, Object::Entity* thisEntity) override;
BoxColliderBounds getBounds() const { return mBounds; }
bool isColliding() const { return mIsColliding; }
private:
BoxColliderBounds mBounds;
bool mIsColliding = false; // Whether this collider is currently colliding with another collider; used to determine whether to call onCollisionEnter vs onCollisionStay, and to call onCollisionExit when collisions end
};
}