This commit is contained in:
parent
126c67e5dd
commit
ec8a193146
10 changed files with 348 additions and 11 deletions
Binary file not shown.
|
@ -137,7 +137,8 @@ platform_src := platform \
|
|||
psoil \
|
||||
pbubtube \
|
||||
pgbubble \
|
||||
pfblock
|
||||
pfblock \
|
||||
pghost
|
||||
|
||||
hazard_src := hazard \
|
||||
hfalling \
|
||||
|
|
|
@ -15,6 +15,14 @@
|
|||
#include "platform\pghost.h"
|
||||
#endif
|
||||
|
||||
#ifndef __GAME_GAME_H__
|
||||
#include "game\game.h"
|
||||
#endif
|
||||
|
||||
#ifndef __VID_HEADER_
|
||||
#include "system\vid.h"
|
||||
#endif
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -22,12 +30,286 @@ void CNpcGhostTrainPlatform::postInit()
|
|||
{
|
||||
CNpcCartPlatform::postInit();
|
||||
|
||||
m_speedSetting = 0;
|
||||
m_speedSetting = GO_DEFAULT;
|
||||
|
||||
m_carSpeed >>= 8;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcGhostTrainPlatform::processMovement( int _frames )
|
||||
{
|
||||
CNpcCartPlatform::processMovement( _frames );
|
||||
s32 fallSpeed = 2;
|
||||
s8 yMovement = fallSpeed * _frames;
|
||||
s32 distX, distY, heading;
|
||||
s32 groundHeight;
|
||||
s32 moveX = 0;
|
||||
s32 moveY = 0;
|
||||
|
||||
bool pathComplete;
|
||||
|
||||
if ( m_reboundTimer > 0 )
|
||||
{
|
||||
m_reboundTimer -= _frames;
|
||||
}
|
||||
|
||||
if ( !m_playerAttached && !m_falling )
|
||||
{
|
||||
m_playerAttached = true;
|
||||
CPlayer *player = GameScene.getPlayer();
|
||||
|
||||
DVECTOR newPos = Pos;
|
||||
CRECT collisionArea=getCollisionArea();
|
||||
newPos.vy = collisionArea.y1;
|
||||
|
||||
player->setPos( newPos );
|
||||
player->setPlatform( this );
|
||||
m_contact = true;
|
||||
}
|
||||
|
||||
if ( m_isActivated )
|
||||
{
|
||||
if ( m_falling )
|
||||
{
|
||||
m_vertSpeed += 192;
|
||||
|
||||
if ( m_vertSpeed > ( 8 << 8 ) )
|
||||
{
|
||||
m_vertSpeed = 8 << 8;
|
||||
}
|
||||
|
||||
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
||||
|
||||
Pos.vy += moveY;
|
||||
|
||||
DVECTOR offset = CLevel::getCameraPos();
|
||||
|
||||
s32 yPos = Pos.vy - offset.vy;
|
||||
|
||||
if ( yPos < 0 || yPos > VidGetScrH() )
|
||||
{
|
||||
setToShutdown();
|
||||
}
|
||||
}
|
||||
else if ( m_rebound )
|
||||
{
|
||||
moveX = -4 * _frames;
|
||||
|
||||
m_vertSpeed += 192;
|
||||
|
||||
if ( m_vertSpeed > ( 8 << 8 ) )
|
||||
{
|
||||
m_vertSpeed = 8 << 8;
|
||||
}
|
||||
else if ( m_vertSpeed < -( 6 << 8 ) )
|
||||
{
|
||||
m_vertSpeed = -( 6 << 8 );
|
||||
}
|
||||
|
||||
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
||||
|
||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
||||
|
||||
if ( groundHeight < 0 )
|
||||
{
|
||||
// have touched down
|
||||
|
||||
m_rebound = false;
|
||||
moveY += groundHeight;
|
||||
}
|
||||
|
||||
Pos.vx += moveX;
|
||||
Pos.vy += moveY;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &heading );
|
||||
|
||||
switch( m_speedSetting )
|
||||
{
|
||||
case GO_DEFAULT:
|
||||
{
|
||||
m_carSpeed = m_speed;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GO_SLOW_DOWN:
|
||||
{
|
||||
m_carSpeed = m_speed - 2;
|
||||
m_speedSetting = GO_DEFAULT;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case GO_SPEED_UP:
|
||||
{
|
||||
m_carSpeed = m_speed + 2;
|
||||
m_speedSetting = GO_DEFAULT;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !pathComplete )
|
||||
{
|
||||
moveX = m_carSpeed * _frames;
|
||||
|
||||
if ( heading == 2048 )
|
||||
{
|
||||
moveX = -moveX;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_inJump )
|
||||
{
|
||||
m_vertSpeed += 192;
|
||||
|
||||
if ( m_vertSpeed > ( 5 << 8 ) )
|
||||
{
|
||||
m_vertSpeed = 5 << 8;
|
||||
}
|
||||
else if ( m_vertSpeed < -( 6 << 8 ) )
|
||||
{
|
||||
m_vertSpeed = -( 6 << 8 );
|
||||
}
|
||||
|
||||
moveY = ( m_vertSpeed >> 8 ) * _frames;
|
||||
|
||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx + moveX, Pos.vy, moveY + 16 );
|
||||
|
||||
if ( groundHeight < moveY )
|
||||
{
|
||||
// have touched down
|
||||
|
||||
m_inJump = false;
|
||||
moveY += groundHeight;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// check for vertical movement
|
||||
|
||||
s32 checkDist = yMovement + 50;
|
||||
|
||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx + moveX, Pos.vy, checkDist );
|
||||
|
||||
if ( groundHeight < checkDist )
|
||||
{
|
||||
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
||||
|
||||
moveY = groundHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall
|
||||
|
||||
moveY = yMovement;
|
||||
}
|
||||
}
|
||||
|
||||
Pos.vx += moveX;
|
||||
Pos.vy += moveY;
|
||||
}
|
||||
|
||||
// sort out draw rotation
|
||||
|
||||
DVECTOR testPos1, testPos2;
|
||||
|
||||
testPos1 = testPos2 = Pos;
|
||||
testPos1.vx -= 10;
|
||||
testPos2.vx += 10;
|
||||
|
||||
u8 sensorDist = 16;
|
||||
|
||||
s32 yDiff;
|
||||
|
||||
yDiff = CGameScene::getCollision()->getHeightFromGroundCart( testPos1.vx, testPos1.vy, sensorDist + 1 );
|
||||
|
||||
if ( yDiff <= sensorDist )
|
||||
{
|
||||
// only use if there is ground present
|
||||
|
||||
testPos1.vy += yDiff;
|
||||
}
|
||||
|
||||
yDiff = CGameScene::getCollision()->getHeightFromGroundCart( testPos2.vx, testPos2.vy, sensorDist + 1 );
|
||||
|
||||
if ( yDiff <= sensorDist )
|
||||
{
|
||||
// only use if there is ground present
|
||||
|
||||
testPos2.vy += yDiff;
|
||||
}
|
||||
|
||||
s32 xDist = testPos2.vx - testPos1.vx;
|
||||
s32 yDist = testPos2.vy - testPos1.vy;
|
||||
|
||||
heading = ratan2( yDist, xDist );
|
||||
|
||||
setCollisionAngle( heading );
|
||||
|
||||
switch ( CGameScene::getCollision()->getCollisionBlock( testPos2.vx, testPos2.vy - 8 ) & COLLISION_TYPE_MASK )
|
||||
{
|
||||
case COLLISION_TYPE_FLAG_DAMAGE:
|
||||
{
|
||||
if ( m_reboundTimer <= 0 )
|
||||
{
|
||||
m_vertSpeed = -8 << 8;
|
||||
m_reboundTimer = 2 * GameState::getOneSecondInFrames();
|
||||
m_rebound = true;
|
||||
Pos.vy -= 8;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case COLLISION_TYPE_FLAG_DEATH_FALL:
|
||||
{
|
||||
m_playerAttached = false;
|
||||
m_falling = true;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
groundHeight = CGameScene::getCollision()->getHeightFromGroundCart( Pos.vx, Pos.vy, yMovement + 16 );
|
||||
|
||||
if ( groundHeight <= yMovement )
|
||||
{
|
||||
moveY = groundHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
// fall
|
||||
|
||||
moveY = yMovement;
|
||||
}
|
||||
|
||||
Pos.vy += moveY;
|
||||
|
||||
if ( m_contact )
|
||||
{
|
||||
m_isActivated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcGhostTrainPlatform::slowDown()
|
||||
{
|
||||
m_speedSetting = GO_SLOW_DOWN;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void CNpcGhostTrainPlatform::speedUp()
|
||||
{
|
||||
m_speedSetting = GO_SPEED_UP;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,19 @@ class CNpcGhostTrainPlatform : public CNpcCartPlatform
|
|||
{
|
||||
public:
|
||||
void postInit();
|
||||
void slowDown();
|
||||
void speedUp();
|
||||
protected:
|
||||
void processMovement( int _frames );
|
||||
|
||||
u8 m_speedSetting;
|
||||
|
||||
enum
|
||||
{
|
||||
GO_DEFAULT = 0,
|
||||
GO_SLOW_DOWN = 1,
|
||||
GO_SPEED_UP,
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
|
@ -550,6 +550,18 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
|
|||
0,
|
||||
NPC_PLATFORM_TIMER_NONE,
|
||||
},
|
||||
|
||||
{ // NPC_GHOST_TRAIN_PLATFORM
|
||||
4,
|
||||
128,
|
||||
true,
|
||||
DAMAGE__NONE,
|
||||
0,
|
||||
4,
|
||||
NPC_PLATFORM_INFINITE_LIFE,
|
||||
4,
|
||||
NPC_PLATFORM_TIMER_NONE,
|
||||
},
|
||||
};
|
||||
|
||||
CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATFORM_TYPE_MAX] =
|
||||
|
@ -593,6 +605,7 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF
|
|||
NPC_STEERABLE_OILDRUM_PLATFORM,
|
||||
NPC_BUBBLE_TUBE_PLATFORM,
|
||||
NPC_FALLING_BLOCK_PLATFORM,
|
||||
NPC_GHOST_TRAIN_PLATFORM,
|
||||
NPC_CONVEYOR_PLATFORM,
|
||||
NPC_PLAYER_BUBBLE_PLATFORM,
|
||||
NPC_CLAM_PLATFORM,
|
||||
|
|
|
@ -211,6 +211,10 @@
|
|||
#include "platform\pfblock.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLATFORM_PGHOST_H__
|
||||
#include "platform\pghost.h"
|
||||
#endif
|
||||
|
||||
#include "fx\fx.h"
|
||||
#include "fx\fxjfish.h"
|
||||
|
||||
|
@ -473,6 +477,12 @@ CNpcPlatform *CNpcPlatform::Create(int Type)
|
|||
break;
|
||||
}
|
||||
|
||||
case NPC_GHOST_TRAIN_PLATFORM:
|
||||
{
|
||||
platform = new ("ghost train platform") CNpcGhostTrainPlatform;
|
||||
break;
|
||||
}
|
||||
|
||||
case NPC_CLAM_PLATFORM:
|
||||
{
|
||||
platform = new ("clam platform") CNpcClamPlatform;
|
||||
|
|
|
@ -96,6 +96,7 @@ public:
|
|||
NPC_STEERABLE_OILDRUM_PLATFORM,
|
||||
NPC_BUBBLE_TUBE_PLATFORM,
|
||||
NPC_FALLING_BLOCK_PLATFORM,
|
||||
NPC_GHOST_TRAIN_PLATFORM,
|
||||
NPC_PLATFORM_TYPE_MAX,
|
||||
};
|
||||
enum
|
||||
|
@ -124,6 +125,8 @@ public:
|
|||
virtual void trigger() {;}
|
||||
virtual u8 isCart() {return( false );}
|
||||
virtual void jump() {;}
|
||||
virtual void slowDown() {;}
|
||||
virtual void speedUp() {;}
|
||||
virtual void leftThinkZone(int _frames);
|
||||
s16 getCollisionAngle() {return m_collisionAngle;}
|
||||
virtual CRECT const *getThinkBBox() {return &m_thinkArea;}
|
||||
|
|
|
@ -83,22 +83,33 @@ void CPlayerStateCart::enter(CPlayerModeBase *_playerMode)
|
|||
---------------------------------------------------------------------- */
|
||||
void CPlayerStateCart::think(CPlayerModeBase *_playerMode)
|
||||
{
|
||||
int controlDown;
|
||||
int controlDown, controlHeld;
|
||||
|
||||
if ( _playerMode->advanceAnimFrameAndCheckForEndOfAnim() )
|
||||
{
|
||||
_playerMode->setAnimNo( ANIM_SPONGEBOB_IDLEBREATH );
|
||||
}
|
||||
controlDown=_playerMode->getPadInputDown();
|
||||
controlHeld=_playerMode->getPadInputHeld();
|
||||
|
||||
if(controlDown&PI_JUMP)
|
||||
CNpcPlatform *platform;
|
||||
platform = (CNpcPlatform *) _playerMode->getPlayer()->isOnPlatform();
|
||||
|
||||
if ( platform )
|
||||
{
|
||||
CNpcPlatform *platform;
|
||||
platform = (CNpcPlatform *) _playerMode->getPlayer()->isOnPlatform();
|
||||
if(controlDown&PI_JUMP)
|
||||
{
|
||||
platform->jump();
|
||||
}
|
||||
|
||||
ASSERT( platform );
|
||||
|
||||
platform->jump();
|
||||
if ( controlHeld & PI_LEFT )
|
||||
{
|
||||
platform->slowDown();
|
||||
}
|
||||
else if ( controlHeld & PI_RIGHT )
|
||||
{
|
||||
platform->speedUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ BendyBranchLeft=11
|
|||
BendyBranchRight=11
|
||||
CoasterCar=9
|
||||
Seesaw=12
|
||||
GhostTrain=9
|
||||
GhostTrain=39
|
||||
Barrel=2
|
||||
OilDrum=13
|
||||
OilDrumGenerator=17
|
||||
|
|
|
@ -1633,6 +1633,14 @@ SOURCE=..\..\..\source\platform\pgeyser.h
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\platform\pghost.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\platform\pghost.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\source\platform\pjellfsh.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
Loading…
Add table
Reference in a new issue