Commit 630b9aeb authored by Gerhard Stein's avatar Gerhard Stein

CBounder is not linked with the platform physics

parent 43ad0dfc
......@@ -24,8 +24,8 @@ const int HOR_SPEED = 40;
CBounder::CBounder(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y),
CStunnable(pmap, foeID, x, y),
CPlatform(pmap, foeID, x, y),
bounceboost(0)
bounceboost(0),
mp_CarriedPlayer(NULL)
{
mActionMap[A_BOUNDER_BOUNCE] = (void (CStunnable::*)()) &CBounder::processBounce;
//mActionMap[A_BOUNDER_MOVE] = (void (CStunnable::*)()) &CBounder::;
......@@ -43,7 +43,17 @@ void CBounder::getTouchedBy(CSpriteObject &theObject)
return;
CStunnable::getTouchedBy(theObject);
CPlatform::getTouchedBy(theObject);
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
const int m_py2 = player->getYDownPos();
const int m_y2 = getYUpPos()+(4<<STC);
if( m_py2 <= m_y2 && !player->supportedbyobject && !player->m_jumpdownfromobject )
{
mp_CarriedPlayer = player;
player->supportedbyobject = true;
}
}
// Was it a bullet? Than make it stunned.
if( theObject.exists && dynamic_cast<CBullet*>(&theObject) )
......@@ -109,6 +119,32 @@ void CBounder::processBounce()
}
}
void CBounder::movePlatLeft(const int amnt)
{
// First move the object on platform if any
if(mp_CarriedPlayer)
{
if(!mp_CarriedPlayer->m_jumpdownfromobject)
mp_CarriedPlayer->moveLeft(amnt);
}
// Now move the platform itself.
moveLeft(amnt);
}
void CBounder::movePlatRight(const int amnt)
{
// First move the object on platform if any
if(mp_CarriedPlayer)
{
if(!mp_CarriedPlayer->m_jumpdownfromobject)
mp_CarriedPlayer->moveRight(amnt);
}
// Now move the platform itself.
moveRight(amnt);
}
void CBounder::movePlayerUp(const int amnt)
{
// First move the object on platform if any
......@@ -132,8 +168,8 @@ void CBounder::movePlayerDown(const int amnt)
void CBounder::process()
{
if(yinertia < 0)
movePlayerUp(-yinertia);
/*if(yinertia < 0)
movePlayerUp(-yinertia);*/
// Bounce
......@@ -154,7 +190,19 @@ void CBounder::process()
setAction( A_BOUNDER_MOVE+1 );
}
CPlatform::process();
// check if someone is still standing on the platform
if(mp_CarriedPlayer)
{
if(!hitdetect(*mp_CarriedPlayer) || mp_CarriedPlayer->blockedu)
{
mp_CarriedPlayer->supportedbyobject = false;
mp_CarriedPlayer->m_jumpdownfromobject = false;
mp_CarriedPlayer = NULL;
}
}
processActionRoutine();
}
};
......@@ -9,11 +9,11 @@
#define CBOUNDER_H_
#include "engine/galaxy/ai/CStunnable.h"
#include "engine/galaxy/ai/platform/CPlatform.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
namespace galaxy {
class CBounder : public CStunnable, public CPlatform
class CBounder : public CStunnable
{
public:
CBounder(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y);
......@@ -21,6 +21,8 @@ public:
void getTouchedBy(CSpriteObject &theObject);
void processBounce();
void movePlatLeft(const int amnt);
void movePlatRight(const int amnt);
void movePlayerUp(const int amnt);
void movePlayerDown(const int amnt);
......@@ -28,6 +30,8 @@ public:
private:
int bounceboost;
CPlayerLevel *mp_CarriedPlayer;
};
};
......
......@@ -15,10 +15,13 @@
namespace galaxy {
#define A_PLATFORM_MOVE 0 /* Ordinary moving platform */
#define A_PLATFORM_SIT 1 /* Dropping platform waiting for passenger */
#define A_PLATFORM_DROP 2 /* Dropping platform dropping */
#define A_PLATFORM_RISE 3 /* Dropping platform rising */
enum platform_actions
{
A_PLATFORM_MOVE = 0, /* Ordinary moving platform */
A_PLATFORM_SIT = 1, /* Dropping platform waiting for passenger */
A_PLATFORM_DROP = 2, /* Dropping platform dropping */
A_PLATFORM_RISE = 3 /* Dropping platform rising */
};
class CPlatform : public virtual CGalaxySpriteObject
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment