box collider
This commit is contained in:
@@ -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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user