Add some collision bars.

This commit is contained in:
King_DuckZ 2014-07-28 11:03:39 +02:00
parent cdaffe0f2b
commit f52476a4ec
4 changed files with 18 additions and 1 deletions

View file

@ -28,6 +28,7 @@ namespace cloonel {
Character::Character (const std::string& parPath, SDLMain* parMain, float2 parSize) : Character::Character (const std::string& parPath, SDLMain* parMain, float2 parSize) :
Placeable(float2(0.0f)), Placeable(float2(0.0f)),
Drawable(parSize), Drawable(parSize),
m_bottomBar(float2(0.0f), parSize.x()),
m_screenRatio(parMain), m_screenRatio(parMain),
m_texture(new Texture(parPath, parMain, false)) m_texture(new Texture(parPath, parMain, false))
{ {
@ -39,6 +40,7 @@ namespace cloonel {
Character::Character (const std::string&& parPath, SDLMain* parMain, float2 parSize) : Character::Character (const std::string&& parPath, SDLMain* parMain, float2 parSize) :
Placeable(float2(0.0f)), Placeable(float2(0.0f)),
Drawable(parSize), Drawable(parSize),
m_bottomBar(float2(0.0f), parSize.x()),
m_screenRatio(parMain), m_screenRatio(parMain),
m_texture(new Texture(parPath, parMain, false)) m_texture(new Texture(parPath, parMain, false))
{ {

View file

@ -24,6 +24,7 @@
#include "drawable.hpp" #include "drawable.hpp"
#include "vector.hpp" #include "vector.hpp"
#include "sizenotifiable.hpp" #include "sizenotifiable.hpp"
#include "horzcollisionbar.hpp"
#include <string> #include <string>
#include <memory> #include <memory>
@ -42,6 +43,7 @@ namespace cloonel {
virtual void Draw ( void ) const; virtual void Draw ( void ) const;
private: private:
HorzCollisionBar m_bottomBar;
SizeNotifiable<regbehaviours::AutoRegister> m_screenRatio; SizeNotifiable<regbehaviours::AutoRegister> m_screenRatio;
const std::unique_ptr<Texture> m_texture; const std::unique_ptr<Texture> m_texture;
}; };

View file

@ -26,6 +26,7 @@ namespace cloonel {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
Platform::Platform (SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize) : Platform::Platform (SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize) :
Placeable(parPos), Placeable(parPos),
m_collisionTop(parPos, parSize.x()),
m_screenRatio(parSdlMain), m_screenRatio(parSdlMain),
m_size(parSize), m_size(parSize),
m_surface(parTexture) m_surface(parTexture)
@ -37,6 +38,7 @@ namespace cloonel {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
Platform::Platform (Platform&& parOther) noexcept : Platform::Platform (Platform&& parOther) noexcept :
Placeable(parOther.GetPos()), Placeable(parOther.GetPos()),
m_collisionTop(parOther.m_collisionTop),
m_screenRatio(std::move(parOther.m_screenRatio)), m_screenRatio(std::move(parOther.m_screenRatio)),
m_size(parOther.m_size), m_size(parOther.m_size),
m_surface(parOther.m_surface) m_surface(parOther.m_surface)
@ -59,4 +61,10 @@ namespace cloonel {
m_surface = parOther.m_surface; m_surface = parOther.m_surface;
return *this; return *this;
} }
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void Platform::OnRegister (Mover& parMover, Mover::PlaceableTicketType parParentTicket) {
parMover.RegisterPlaceable(&m_collisionTop, parParentTicket);
}
} //namespace cloonel } //namespace cloonel

View file

@ -23,6 +23,7 @@
#include "sizenotifiable.hpp" #include "sizenotifiable.hpp"
#include "drawable.hpp" #include "drawable.hpp"
#include "placeable.hpp" #include "placeable.hpp"
#include "horzcollisionbar.hpp"
namespace cloonel { namespace cloonel {
class Texture; class Texture;
@ -36,11 +37,15 @@ namespace cloonel {
virtual ~Platform ( void ) noexcept = default; virtual ~Platform ( void ) noexcept = default;
Platform& operator= ( const Platform& parOther ); Platform& operator= ( const Platform& parOther );
virtual void Draw ( void ) const;
float2 TopLeft ( void ) const { return GetPos(); } float2 TopLeft ( void ) const { return GetPos(); }
float2 BottomRight ( void ) const { return TopLeft() + m_size; } float2 BottomRight ( void ) const { return TopLeft() + m_size; }
//Overrides
virtual void Draw ( void ) const;
virtual void OnRegister ( Mover& parMover, Mover::PlaceableTicketType parParentTicket );
private: private:
HorzCollisionBar m_collisionTop;
SizeNotifiable<regbehaviours::AutoRegister> m_screenRatio; SizeNotifiable<regbehaviours::AutoRegister> m_screenRatio;
float2 m_size; float2 m_size;
Texture* m_surface; Texture* m_surface;