Add code to register objects to the collider.

The character and the platforms can register now, but
collision is not triggered for some reason.
This commit is contained in:
King_DuckZ 2014-08-01 00:50:49 +02:00
parent 42fb50e93e
commit cdd37fead7
13 changed files with 133 additions and 10 deletions

View file

@ -19,16 +19,18 @@
#include "platform.hpp"
#include "texture.hpp"
#include "horzcollisionbar.hpp"
#include <cassert>
#include <algorithm>
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_collisionTop(new HorzCollisionBar(parPos, parSize.x())),
m_surface(parTexture)
{
assert(m_surface);
@ -38,13 +40,18 @@ 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_collisionTop(std::move(parOther.m_collisionTop)),
m_surface(parOther.m_surface)
{
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
Platform::~Platform() noexcept {
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void Platform::Draw() const {
@ -65,6 +72,12 @@ namespace cloonel {
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void Platform::OnRegister (Mover& parMover, Mover::PlaceableTicketType parParentTicket) {
parMover.RegisterPlaceable(&m_collisionTop, parParentTicket);
parMover.RegisterPlaceable(m_collisionTop.get(), parParentTicket);
}
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
void Platform::RegisterForCollision (ColliderRegisterFunc parReg) {
parReg(m_collisionTop.get());
}
} //namespace cloonel