From 8142a9c87a13cecc7a3698e877f24d89f128c074 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 21 Apr 2018 14:50:52 -0400 Subject: Started working on prototype objects --- src/components/ponderable.h | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'src/components/ponderable.h') diff --git a/src/components/ponderable.h b/src/components/ponderable.h index 78af25f..da509a2 100644 --- a/src/components/ponderable.h +++ b/src/components/ponderable.h @@ -2,22 +2,44 @@ #define TANGIBLE_H_746DB3EE #include "component.h" +#include +#include + +class Game; class PonderableComponent : public Component { public: - enum class Type { + enum class BodyType { vacuumed, freefalling }; - PonderableComponent(Type type) : type_(type) + enum class ColliderType { + player, + event + }; + + static const size_t COLLIDER_TYPES = 2; + + PonderableComponent( + BodyType bodyType, + ColliderType colliderType) : + bodyType_(bodyType), + colliderType_(colliderType) + { + } + + using event_callback_type = std::function; + + inline BodyType getBodyType() const { + return bodyType_; } - inline Type getType() const + inline ColliderType getColliderType() const { - return type_; + return colliderType_; } inline double getVelocityX() const @@ -90,16 +112,28 @@ public: collidable_ = v; } + inline const event_callback_type& getEventCallback(ColliderType v) const + { + return eventCallbacks_[static_cast(v)]; + } + + inline void setEventCallback(ColliderType v, event_callback_type callback) + { + eventCallbacks_[static_cast(v)] = std::move(callback); + } + private: double velX_ = 0.0; double velY_ = 0.0; double accelX_ = 0.0; double accelY_ = 0.0; - Type type_ = Type::vacuumed; + BodyType bodyType_; + ColliderType colliderType_; bool grounded_ = false; bool frozen_ = false; bool collidable_ = true; + std::array eventCallbacks_; }; #endif /* end of include guard: TANGIBLE_H_746DB3EE */ -- cgit 1.4.1