diff --git a/src/character.cpp b/src/character.cpp index 0e763a1..0e4370f 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -28,6 +28,7 @@ namespace cloonel { Character::Character (const std::string& parPath, SDLMain* parMain, float2 parSize) : Placeable(float2(0.0f)), Drawable(parSize), + m_bottomBar(float2(0.0f), parSize.x()), m_screenRatio(parMain), m_texture(new Texture(parPath, parMain, false)) { @@ -39,6 +40,7 @@ namespace cloonel { Character::Character (const std::string&& parPath, SDLMain* parMain, float2 parSize) : Placeable(float2(0.0f)), Drawable(parSize), + m_bottomBar(float2(0.0f), parSize.x()), m_screenRatio(parMain), m_texture(new Texture(parPath, parMain, false)) { diff --git a/src/character.hpp b/src/character.hpp index 620e7f4..d758723 100644 --- a/src/character.hpp +++ b/src/character.hpp @@ -24,6 +24,7 @@ #include "drawable.hpp" #include "vector.hpp" #include "sizenotifiable.hpp" +#include "horzcollisionbar.hpp" #include #include @@ -42,6 +43,7 @@ namespace cloonel { virtual void Draw ( void ) const; private: + HorzCollisionBar m_bottomBar; SizeNotifiable m_screenRatio; const std::unique_ptr m_texture; }; diff --git a/src/platform.cpp b/src/platform.cpp index f216229..59ee713 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -26,6 +26,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- Platform::Platform (SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize) : Placeable(parPos), + m_collisionTop(parPos, parSize.x()), m_screenRatio(parSdlMain), m_size(parSize), m_surface(parTexture) @@ -37,6 +38,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- Platform::Platform (Platform&& parOther) noexcept : Placeable(parOther.GetPos()), + m_collisionTop(parOther.m_collisionTop), m_screenRatio(std::move(parOther.m_screenRatio)), m_size(parOther.m_size), m_surface(parOther.m_surface) @@ -59,4 +61,10 @@ namespace cloonel { m_surface = parOther.m_surface; return *this; } + + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + void Platform::OnRegister (Mover& parMover, Mover::PlaceableTicketType parParentTicket) { + parMover.RegisterPlaceable(&m_collisionTop, parParentTicket); + } } //namespace cloonel diff --git a/src/platform.hpp b/src/platform.hpp index 0e687b0..cf7e0c6 100644 --- a/src/platform.hpp +++ b/src/platform.hpp @@ -23,6 +23,7 @@ #include "sizenotifiable.hpp" #include "drawable.hpp" #include "placeable.hpp" +#include "horzcollisionbar.hpp" namespace cloonel { class Texture; @@ -36,11 +37,15 @@ namespace cloonel { virtual ~Platform ( void ) noexcept = default; Platform& operator= ( const Platform& parOther ); - virtual void Draw ( void ) const; float2 TopLeft ( void ) const { return GetPos(); } float2 BottomRight ( void ) const { return TopLeft() + m_size; } + //Overrides + virtual void Draw ( void ) const; + virtual void OnRegister ( Mover& parMover, Mover::PlaceableTicketType parParentTicket ); + private: + HorzCollisionBar m_collisionTop; SizeNotifiable m_screenRatio; float2 m_size; Texture* m_surface;