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/mappable.h | 6 ++++++ src/components/playable.h | 2 ++ src/components/ponderable.h | 44 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 5 deletions(-) (limited to 'src/components') diff --git a/src/components/mappable.h b/src/components/mappable.h index 633cdf4..e26326d 100644 --- a/src/components/mappable.h +++ b/src/components/mappable.h @@ -125,6 +125,11 @@ public: font_ = std::move(v); } + inline std::map& getInstances() + { + return instances_; + } + private: size_t mapId_ = -1; @@ -135,6 +140,7 @@ private: asc_boundaries_type downBoundaries_; Texture tileset_; Texture font_; + std::map instances_; }; #endif /* end of include guard: MAPPABLE_H_0B0316FB */ diff --git a/src/components/playable.h b/src/components/playable.h index 86a7ee7..0d91929 100644 --- a/src/components/playable.h +++ b/src/components/playable.h @@ -18,6 +18,8 @@ public: int checkpointMapId = -1; double checkpointX = 0; double checkpointY = 0; + bool checkpointObjectActivated = false; + size_t checkpointObjectIndex = 0; }; 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