Commit d4ef5612 authored by Gerhard Stein's avatar Gerhard Stein

Fixed some bugs. Fault of new srite class design, now Vorticon works again correctly

parent 94f2f990
......@@ -437,7 +437,8 @@ int CSpriteObject::checkSolidD( int x1, int x2, int y2, const bool push_mode )
blocked = TileProperty[mp_Map->at(c>>CSF, y2>>CSF)].bup;
if( blocked && (blocked < 2 || blocked > 7) )
return TileProperty[mp_Map->at(c>>CSF, y2>>CSF)].bdown;
//return TileProperty[mp_Map->at(c>>CSF, y2>>CSF)].bdown;
return blocked;
}
blocked = TileProperty[mp_Map->at((x2-(1<<STC))>>CSF, y2>>CSF)].bup;
......
......@@ -74,8 +74,14 @@ void CPlayer::setDatatoZero()
ankhtime = 0;
exists = true;
onscreen = true;
pfallspeed = 0,
pdir = pshowdir = (m_level==80) ? DOWN : RIGHT;
pfallspeed = 0;
if(m_level==80)
pShowDir = VectorD2<direction_t>(CENTER,DOWN);
else
pShowDir = VectorD2<direction_t>(RIGHT,CENTER);
pDir = pShowDir;
inhibitfall = hideplayer = false;
pwalkframe = pwalkframea = 0;
dpadcount = 0;
......@@ -131,7 +137,7 @@ void CPlayer::setupforLevelPlay()
{
plastfalling = true;
solid = true;
pshowdir = RIGHT;
pShowDir.x = RIGHT;
ppogostick = false;
pjumping = PNOJUMP;
psliding = psemisliding = false;
......@@ -181,8 +187,8 @@ void CPlayer::Walking()
// this prevents a "slipping" effect if you jump, say, right, then
// start walking left just as you hit the ground
if (pjustjumped && ((xinertia > 0 && pdir==LEFT) ||
(xinertia < 0 && pdir==RIGHT)))
if (pjustjumped && ((xinertia > 0 && pDir.x == LEFT) ||
(xinertia < 0 && pDir.x == RIGHT)))
{
if(!ppogostick)
xinertia = 0;
......@@ -201,10 +207,10 @@ void CPlayer::Walking()
// don't move!.
if (pjustfell && psemisliding)
{
if (pdir==RIGHT)
pjustfell = blockedr ? 0 : pdir;
if (pDir.x==RIGHT)
pjustfell = blockedr ? 0 : pDir.x;
else
pjustfell = blockedl ? 0 : pdir;
pjustfell = blockedl ? 0 : pDir.x;
}
}
......@@ -212,7 +218,7 @@ void CPlayer::Walking()
if ((psemisliding && xinertia!=0) || (((playcontrol[PA_X] < 0) || (playcontrol[PA_X] > 0) || (( (playcontrol[PA_Y] < 0) || (playcontrol[PA_Y] > 0)) && m_playingmode == WORLDMAP )) && !inhibitwalking))
{
// we just started walking or we changed directions suddenly?
if (pwalking == 0 || ((lastpdir==RIGHT && pdir==LEFT)||(lastpdir==LEFT && pdir==RIGHT)))
if (pwalking == 0 || ((lastPDir.x==RIGHT && pDir.x==LEFT)||(lastPDir.x==LEFT && pDir.x==RIGHT)))
{
pwalkanimtimer = 0;
pwalkframe = 1;
......@@ -225,7 +231,7 @@ void CPlayer::Walking()
pinertia_y = 0;
}
lastpdir = pdir;
lastPDir = pDir;
pwalking = 1;
}
}
......@@ -252,9 +258,9 @@ void CPlayer::Walking()
// reset walk frame because we have no walk animation while on ice
pwalkframe = 0;
// keep player sliding at maximum speed
if (pdir==RIGHT)
if (pDir.x==RIGHT)
xinertia = pmaxspeed;
else if (pdir==LEFT)
else if (pDir.x==LEFT)
xinertia = -pmaxspeed;
}
return;
......@@ -456,10 +462,10 @@ void CPlayer::WalkingAnimation()
// Check if the player walking against walls (solid tiles)
bool obs=false;
obs |= (blockedu && pdir == UP);
obs |= (blockedd && pdir == DOWN);
obs |= (blockedl && pdir == LEFT);
obs |= (blockedr && pdir == RIGHT);
obs |= (blockedu && pDir.y == UP);
obs |= (blockedd && pDir.y == DOWN);
obs |= (blockedl && pDir.x == LEFT);
obs |= (blockedr && pDir.x == RIGHT);
if (obs)
playSound(SOUND_KEEN_BUMPHEAD);
......@@ -751,7 +757,7 @@ void CPlayer::ProcessExitLevel()
walkbehindexitdoor();
// keep him going right
pdir = pshowdir = RIGHT;
pDir.x = pShowDir.x = RIGHT;
// make keen walk slowly through the exit door
playcontrol[PA_X] = 80;
if (xinertia > PMAXEXITDOORSPEED)
......
......@@ -152,7 +152,8 @@ public:
unsigned char pjumpfloattimer;
size_t ankhtime;
direction_t pdir,pshowdir,lastpdir;
VectorD2<int> pDir,pShowDir,lastPDir;
char pfireframetimer;
bool inhibitwalking;
......
......@@ -250,8 +250,8 @@ void CPlayer::setDir()
if (psliding && pjumping < PJUMPED)
{
bool stuck = false;
if (pshowdir == LEFT && blockedl) stuck = true;
if (pshowdir == RIGHT && blockedr) stuck = true;
if (pShowDir.x == LEFT && blockedl) stuck = true;
if (pShowDir.x == RIGHT && blockedr) stuck = true;
if (stuck)
{
// jumped off an ice block into a wall?
......@@ -269,13 +269,13 @@ void CPlayer::setDir()
if (!pjumping && !pfiring)
{
if (playcontrol[PA_X] < 0 && xinertia < 0) { pdir = pshowdir = LEFT; }
if (playcontrol[PA_X] > 0 && xinertia > 0) { pdir = pshowdir = RIGHT; }
if (playcontrol[PA_X] < 0 && xinertia < 0) { pDir.x = pShowDir.x = LEFT; }
if (playcontrol[PA_X] > 0 && xinertia > 0) { pDir.x = pShowDir.x = RIGHT; }
}
else
{
if (playcontrol[PA_X] < 0) { pdir = pshowdir = LEFT; }
if (playcontrol[PA_X] > 0) { pdir = pshowdir = RIGHT; }
if (playcontrol[PA_X] < 0) { pDir.x = pShowDir.x = LEFT; }
if (playcontrol[PA_X] > 0) { pDir.x = pShowDir.x = RIGHT; }
}
}
......@@ -479,8 +479,8 @@ void CPlayer::JumpAndPogo()
pwalkframe = 1;
if ( psliding )
{ // on ice, always jump direction facing
if (pshowdir==LEFT) pdir=LEFT;
else pdir=RIGHT;
if (pShowDir.x==LEFT) pDir.x=LEFT;
else pDir.x=RIGHT;
}
else
pjumpdir = UP;
......@@ -754,19 +754,19 @@ void CPlayer::raygun()
{ // we have enough charges
int xdir, ydir;
// In case the player hasn't any direction assignedyet, because he can only shoot in those two directions
if(pdir != LEFT) pdir = RIGHT;
// In case the player hasn't any direction assigned yet, because he can only shoot in those two directions
if(pDir.x != LEFT) pDir.x = RIGHT;
inventory.charges--;
pshowdir = pdir;
pShowDir = pDir;
playSound( SOUND_KEEN_FIRE );
ydir = getYPosition()+(9<<STC);
if (pdir==RIGHT) xdir = getXRightPos()+xinertia;
if (pDir.x == RIGHT) xdir = getXRightPos()+xinertia;
else xdir = getXLeftPos()+xinertia-(16<<STC);
CRay *rayobject = new CRay(mp_Map, xdir, ydir, pdir, OBJ_PLAYER, m_index);
CRay *rayobject = new CRay(mp_Map, xdir, ydir, static_cast<direction_t>(pDir.x), OBJ_PLAYER, m_index);
rayobject->setSpeed(124);
mp_object->push_back(rayobject);
......@@ -818,7 +818,7 @@ void CPlayer::SelectFrame()
// if he's going left switch the frame selected above to the
// appropriate one for the left direction
if (pshowdir==LEFT && !pdie && !pfrozentime)
if (pShowDir.x == LEFT && !pdie && !pfrozentime)
{
if (pfiring)
{
......@@ -852,7 +852,7 @@ void CPlayer::bump( CSpriteObject &theObject, direction_t direction )
playSound( SOUND_YORP_BUMP, PLAY_NORESTART );
if(!pfiring)
pshowdir = pdir = direction;
pShowDir.x = pDir.x = direction;
xinertia = (direction==RIGHT) ? bumpamount : -bumpamount;
......@@ -875,13 +875,13 @@ void CPlayer::push( CSpriteObject &theObject )
if( midx < obj_midx )
{
moveLeft(rx - obj_lx);
pdir = pshowdir = LEFT;
pDir.x = pShowDir.x = LEFT;
}
if( midx > obj_midx )
{
moveRight(obj_rx - lx);
pdir = pshowdir = RIGHT;
pDir.x = pShowDir.x = RIGHT;
}
pwalking = true;
}
......
......@@ -48,21 +48,21 @@ void CPlayer::setWorldMapdir()
{
bool exception=false;
dpadcount = 0;
if (playcontrol[PA_X] < 0) { pdir = LEFT; dpadcount++; }
if (playcontrol[PA_X] > 0) { pdir = RIGHT; dpadcount++; }
if (playcontrol[PA_Y] < 0) { pdir = UP; dpadcount++; }
if (playcontrol[PA_Y] > 0) { pdir = DOWN; dpadcount++; }
if (playcontrol[PA_X] < 0) { pDir.x = LEFT; pDir.y = 0; dpadcount++; }
if (playcontrol[PA_X] > 0) { pDir.x = RIGHT; pDir.y = 0; dpadcount++; }
if (playcontrol[PA_Y] < 0) { pDir.y = UP; pDir.x = 0; dpadcount++; }
if (playcontrol[PA_Y] > 0) { pDir.y = DOWN; pDir.x = 0; dpadcount++; }
if ( pshowdir==UP && !playcontrol[PA_Y] < 0) exception = true;
if ( pshowdir==DOWN && !playcontrol[PA_Y] > 0) exception = true;
if ( pshowdir==LEFT && !playcontrol[PA_X] < 0) exception = true;
if ( pshowdir==RIGHT && !playcontrol[PA_X] > 0) exception = true;
if ( pShowDir.y == UP && !playcontrol[PA_Y] < 0) exception = true;
if ( pShowDir.y == DOWN && !playcontrol[PA_Y] > 0) exception = true;
if ( pShowDir.x == LEFT && !playcontrol[PA_X] < 0) exception = true;
if ( pShowDir.x == RIGHT && !playcontrol[PA_X] > 0) exception = true;
if (playcontrol[PA_Y] < 0) pshowdir = UP;
if (playcontrol[PA_Y] > 0) pshowdir = DOWN;
if (playcontrol[PA_Y] < 0) pShowDir.y = UP;
if (playcontrol[PA_Y] > 0) pShowDir.y = DOWN;
if (dpadcount==1 || dpadlastcount==0 || exception)
pshowdir = pdir;
pShowDir = pDir;
dpadlastcount = dpadcount;
}
......@@ -147,10 +147,10 @@ void CPlayer::verifySolidLevels()
void CPlayer::selectFrameOnWorldMap()
{
// select base frame for current direction
if (pshowdir==RIGHT) sprite = playerbaseframe + PMAPRIGHTFRAME;
else if (pshowdir==LEFT) sprite = playerbaseframe + PMAPLEFTFRAME;
else if (pshowdir==UP) sprite = playerbaseframe + PMAPUPFRAME;
else if (pshowdir==DOWN) sprite = playerbaseframe + PMAPDOWNFRAME;
if (pShowDir.x==RIGHT) sprite = playerbaseframe + PMAPRIGHTFRAME;
else if (pShowDir.x==LEFT) sprite = playerbaseframe + PMAPLEFTFRAME;
else if (pShowDir.y==UP) sprite = playerbaseframe + PMAPUPFRAME;
else if (pShowDir.y==DOWN) sprite = playerbaseframe + PMAPDOWNFRAME;
// add in walk frame if walking
if (pwalking) sprite += pwalkframe;
......
......@@ -41,7 +41,7 @@ transluceny(0)
dontdraw = false;
cansupportplayer = false;
dying = false;
yDirection = xDirection = NONE;
yDirection = xDirection = 0;
supportedbyobject = false;
blockedd = false;
......
......@@ -173,7 +173,9 @@ bool CVorticonMapLoader::load( Uint8 episode, Uint8 level, const std::string& pa
if (++resetcnt==resetpt) curmapx = curmapy = 0;
}
}
planeitems.clear();
// Do some post calculations
......@@ -481,7 +483,8 @@ void CVorticonMapLoader::addEnemyObject(unsigned int t, Uint16 x, Uint16 y, int
break;
}
if(enemyobject)
if(enemyobject != NULL)
mp_objvect->push_back(enemyobject);
}
}
......
......@@ -14,7 +14,7 @@
enum direction_t
{
NONE = 0,
CENTER = 0,
RIGHT = 1,
LEFT = -1,
UP = -1,
......
......@@ -285,7 +285,7 @@ void CGalaxySpriteObject::setAction(size_t ActionNumber)
// Sets the proper sprite of action format to the local object
void CGalaxySpriteObject::setActionSprite()
{
if(xDirection == LEFT || xDirection == NONE)
if(xDirection == LEFT || xDirection == 0)
sprite = m_Action.spriteLeft-spriteOffset;
else if(xDirection == RIGHT)
sprite = m_Action.spriteRight-spriteOffset;
......
......@@ -1606,7 +1606,7 @@ void CPlayerLevel::performPoleHandleInput()
}
setAction(A_KEEN_POLE);
yDirection = NONE;
yDirection = 0;
}
......@@ -1660,7 +1660,7 @@ void CPlayerLevel::processPoleClimbingSit()
else
{
setAction(A_KEEN_POLE);
yDirection = NONE;
yDirection = 0;
}
return;
......@@ -1731,7 +1731,7 @@ void CPlayerLevel::processPoleClimbingUp()
else
{
setAction(A_KEEN_POLE);
yDirection = NONE;
yDirection = 0;
}
performPoleHandleInput();
......@@ -1762,7 +1762,7 @@ void CPlayerLevel::processPoleClimbingDown()
{
// Fall down if there isn't any pole to slide down
m_climbing = false;
yDirection = NONE;
yDirection = 0;
yinertia = 0;
solid = true;
......@@ -1872,7 +1872,7 @@ void CPlayerLevel::processFalling()
m_climbing = false;
m_jumped = true;
yinertia = 0;
yDirection = NONE;
yDirection = 0;
return;
}
......
......@@ -107,7 +107,7 @@ void CPlayerWM::processMoving()
if(g_pInput->getHoldedCommand(IC_LEFT) && !bleft)
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
yDirection = NONE;
yDirection = 0;
moveLeft(movespeed);
walking = true;
......@@ -116,7 +116,7 @@ void CPlayerWM::processMoving()
else if(g_pInput->getHoldedCommand(IC_RIGHT) && !bright)
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
yDirection = NONE;
yDirection = 0;
moveRight(movespeed);
walking = true;
......@@ -126,7 +126,7 @@ void CPlayerWM::processMoving()
if(g_pInput->getHoldedCommand(IC_UP) && !bup)
{
if(!g_pInput->getHoldedCommand(IC_LEFT) && !g_pInput->getHoldedCommand(IC_RIGHT))
xDirection = NONE;
xDirection = 0;
moveUp(movespeed);
walking = true;
......@@ -135,7 +135,7 @@ void CPlayerWM::processMoving()
else if(g_pInput->getHoldedCommand(IC_DOWN) && !bdown)
{
if(!g_pInput->getHoldedCommand(IC_LEFT) && !g_pInput->getHoldedCommand(IC_RIGHT))
xDirection = NONE;
xDirection = 0;
moveDown(movespeed);
walking = true;
......@@ -308,11 +308,11 @@ void CPlayerWM::checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdo
*/
void CPlayerWM::performWalkingAnimation(bool walking)
{
if(xDirection == RIGHT && yDirection == NONE)
if(xDirection == RIGHT && yDirection == 0)
sprite = m_basesprite + 1;
else if(xDirection == NONE && yDirection == UP)
else if(xDirection == 0 && yDirection == UP)
sprite = m_basesprite + 4;
else if(xDirection == NONE && yDirection == DOWN)
else if(xDirection == 0 && yDirection == DOWN)
sprite = m_basesprite + 7;
else if(xDirection == RIGHT && yDirection == DOWN)
sprite = m_basesprite + 10;
......@@ -340,11 +340,11 @@ void CPlayerWM::performWalkingAnimation(bool walking)
*/
void CPlayerWM::performSwimmingAnimation()
{
if(xDirection == RIGHT && yDirection == NONE)
if(xDirection == RIGHT && yDirection == 0)
sprite = m_basesprite + 2;
else if(xDirection == NONE && yDirection == DOWN)
else if(xDirection == 0 && yDirection == DOWN)
sprite = m_basesprite + 4;
else if(xDirection == LEFT && yDirection == NONE)
else if(xDirection == LEFT && yDirection == 0)
sprite = m_basesprite + 6;
else if(xDirection == RIGHT && yDirection == UP)
sprite = m_basesprite + 8;
......
......@@ -33,7 +33,7 @@ mpInteractPlayer(NULL)
mActionMap[A_BOUNDER_STUNNED] = &CStunnable::processGettingStunned;
setupGalaxyObjectOnMap(0x2F12, A_BOUNDER_BOUNCE);
xDirection = NONE;
xDirection = 0;
}
......@@ -114,7 +114,7 @@ void CBounder::processOnFloor()
xDirection = RIGHT;
break;
default:
xDirection = NONE;
xDirection = 0;
break;
}
......@@ -131,7 +131,7 @@ void CBounder::processOnFloor()
else if( mMidPX < mMidX - (4<<STC) )
xDirection = LEFT;
else
xDirection = NONE;
xDirection = 0;
}
}
......
......@@ -29,7 +29,7 @@ CGalaxySpriteObject(pmap, foeID, x, y)
setupGalaxyObjectOnMap(0x1A64, action_type);
}
xDirection = NONE;
xDirection = 0;
yDirection = UP;
honorPriority = false;
solid = false;
......
......@@ -32,7 +32,7 @@ CStunnable(pmap, foeID, x, y)
mActionMap[A_MIMROCK_STUNNED] = &CStunnable::processStunned;
setupGalaxyObjectOnMap(0x343A, A_MIMROCK_SIT);
xDirection = NONE;
xDirection = 0;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
......
......@@ -90,7 +90,7 @@ void CPlayerDive::processDiving()
if(g_pInput->getHoldedCommand(IC_LEFT))
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
yDirection = NONE;
yDirection = 0;
moveLeft(MOVESPEED+m_swimupspeed);
xDirection = LEFT;
......@@ -98,7 +98,7 @@ void CPlayerDive::processDiving()
else if(g_pInput->getHoldedCommand(IC_RIGHT))
{
if(!g_pInput->getHoldedCommand(IC_UP) && !g_pInput->getHoldedCommand(IC_DOWN))
yDirection = NONE;
yDirection = 0;
moveRight(MOVESPEED+m_swimupspeed);
xDirection = RIGHT;
......
......@@ -18,7 +18,7 @@ const int MINE_SPEED = 20;
CWaterMine::CWaterMine(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, const bool vertical) :
CGalaxySpriteObject(pmap, foeID, x, y)
{
yDirection = xDirection = NONE;
yDirection = xDirection = 0;
if(vertical)
yDirection = DOWN;
......
......@@ -25,8 +25,8 @@ m_delay_for_drop(0),
m_drop_speed(0),
m_Origin(m_Pos)
{
xDirection = NONE;
yDirection = NONE;
xDirection = 0;
yDirection = 0;
solid = false;
setActionForce(A_PLATFORM_DROP);
setActionSprite();
......
......@@ -15,7 +15,7 @@ CGalaxySpriteObject(pmap, foeID, x, y),
CPlatform(pmap, foeID, x, y)
{
xDirection = RIGHT;
yDirection = NONE;
yDirection = 0;
setActionForce(A_PLATFORM_MOVE);
setActionSprite();
calcBoundingBoxes();
......
......@@ -18,7 +18,7 @@ CPlatformVertical::CPlatformVertical(CMap *pmap, const Uint16 foeID, const Uint3
CGalaxySpriteObject(pmap, foeID, x, y),
CPlatform(pmap, foeID, x, y)
{
xDirection = NONE;
xDirection = 0;
yDirection = DOWN;
setActionForce(A_PLATFORM_MOVE);
setActionSprite();
......
......@@ -78,12 +78,13 @@ void CButler::process()
}
}
void CButler::getTouchedBy(CVorticonSpriteObject &theObject)
void CButler::getTouchedBy(CSpriteObject &theObject)
{ // push keen
if( theObject.m_type == OBJ_PLAYER )
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
Player.bump( *this, movedir );
player->bump( *this, movedir );
}
}
......
......@@ -38,7 +38,7 @@ public:
CButler(CMap *pmap, Uint32 x, Uint32 y,
std::vector<CPlayer> &PlayerVect);
void process();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
int checkSolidD( int x1, int x2, int y2, const bool push_mode=false );
......
......@@ -206,12 +206,11 @@ void CFoob::process()
}
}
void CFoob::getTouchedBy(CVorticonSpriteObject &theObject)
void CFoob::getTouchedBy(CSpriteObject &theObject)
{
if(theObject.m_type == OBJ_PLAYER)
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(g_pBehaviorEngine->mDifficulty==HARD)
Player.kill();
player->kill();
}
}
......@@ -40,7 +40,7 @@ class CFoob : public CVorticonSpriteObject
public:
CFoob(CMap *p_map, Uint32 x, Uint32 y, std::vector<CPlayer>& Player);
void process();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
private:
enum FOOB_ACTIONS
......
......@@ -207,8 +207,11 @@ void CGuardRobot::guard_fire()
pausetime = FIRE_PAUSE_TIME;
}
void CGuardRobot::getTouchedBy(CVorticonSpriteObject &theObject)
void CGuardRobot::getTouchedBy(CSpriteObject &theObject)
{
if (theObject.m_type == OBJ_PLAYER && g_pBehaviorEngine->mDifficulty>=NORMAL)
theObject.kill(); // Only on normal and hard mode when keen touches it, he can die
if ( g_pBehaviorEngine->mDifficulty>=NORMAL )
{
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
player->kill(); // Only on normal and hard mode when keen touches it, he can die
}
}
......@@ -21,7 +21,7 @@ public:
std::vector<CVorticonSpriteObject*>& Object);
void process();
void guard_fire();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
private:
......
......@@ -72,13 +72,13 @@ void CIceChunk::process()
// make him start sliding in the direction of the impact
if (vector_x > 0)
{
m_Player[touchedBy].pdir = m_Player[touchedBy].pshowdir = RIGHT;
m_Player[touchedBy].pDir.x = m_Player[touchedBy].pShowDir.x = RIGHT;
m_Player[touchedBy].xinertia = Physics.player.max_x_speed;
m_Player[touchedBy].bump( *this, RIGHT );
}
else if (vector_x < 0)
{
m_Player[touchedBy].pdir = m_Player[touchedBy].pshowdir = LEFT;
m_Player[touchedBy].pDir.x = m_Player[touchedBy].pShowDir.x = LEFT;
m_Player[touchedBy].xinertia = -Physics.player.max_x_speed;
m_Player[touchedBy].bump( *this, LEFT );
}
......
......@@ -96,16 +96,15 @@ void CPlatform::SetAllCanSupportPlayer(bool state)
}
}
void CPlatform::getTouchedBy(CVorticonSpriteObject &theObject)
void CPlatform::getTouchedBy(CSpriteObject &theObject)
{
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.blockedd or !Player.supportedbyobject)
Player.push(*this);
if(player->pfalling or !player->blockedd or !player->supportedbyobject)
player->push(*this);
else if( state == PLATFORM_MOVE )
Player.moveXDir( (movedir==LEFT) ? -PLATFORM_MOVE_SPD : PLATFORM_MOVE_SPD);
player->moveXDir( (movedir==LEFT) ? -PLATFORM_MOVE_SPD : PLATFORM_MOVE_SPD);
}
}
......@@ -21,7 +21,7 @@ public:
void process();
void SetAllCanSupportPlayer(bool state);
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
protected:
unsigned char state;
......@@ -40,7 +40,7 @@ public:
CPlatformVert(CMap *p_map, Uint32 x, Uint32 y,
std::vector<CPlayer>& Player);
void process();
void getTouchedBy(CVorticonSpriteObject &theObject);
void getTouchedBy(CSpriteObject &theObject);
};
#endif /* CPLATFORM_H_ */
......@@ -130,15 +130,14 @@ void CPlatformVert::process()
}
}
void CPlatformVert::getTouchedBy(CVorticonSpriteObject &theObject)
void CPlatformVert::getTouchedBy(CSpriteObject &theObject)
{
// push player horizontally
if( theObject.m_type == OBJ_PLAYER )
if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) )
{
CPlayer &Player = dynamic_cast<CPlayer&>(theObject);
if(Player.pfalling or !Player.supportedbyobject)
Player.push(*this);
if(player->pfalling or !player->supportedbyobject)
player->push(*this);
else if( state == PLATVERT_MOVE )