This commit is contained in:
Charles 2001-05-23 14:46:23 +00:00
parent c16f9c770b
commit 89aedc2e2e
10 changed files with 91 additions and 160 deletions

View File

@ -121,7 +121,8 @@ platform_src := platform \
pbwheel \
psbarrel \
pjellfsh \
pclam
pclam \
pfishhk3
hazard_src := hazard \
hfalling \

View File

@ -37,25 +37,23 @@
void CNpcBranchPlatform::postInit()
{
sBBox boundingBox = m_modelGfx->GetBBox();
boundingBox.YMin = ( ( boundingBox.YMin - boundingBox.YMax ) >> 1 ) + boundingBox.YMax;
boundingBox.YMin = ( ( boundingBox.YMin - boundingBox.YMax ) >> 1 ) + boundingBox.YMax + 16;
m_boundingBox = boundingBox;
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) - 8, ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
//CNpcPlatform::postInit();
/*sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ) << 1, ( boundingBox.YMax - boundingBox.YMin ) );
calculateNonRotatedCollisionData();
m_angularVelocity = 0;
if ( m_reversed )
{
setCollisionCentreOffset( boundingBox.XMax, 18 + ( ( boundingBox.YMax + boundingBox.YMin ) >> 1 ) );
m_initRotation = 64;
}
else
{
setCollisionCentreOffset( boundingBox.XMin, 18 + ( ( boundingBox.YMax + boundingBox.YMin ) >> 1 ) );
}*/
m_angularVelocity = 0;
m_initRotation = -64;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -100,63 +98,12 @@ void CNpcBranchPlatform::setWaypoints( sThingPlatform *ThisPlatform )
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*void CNpcBranchPlatform::collidedWith( CThing *_thisThing )
{
switch(_thisThing->getThingType())
{
case TYPE_PLAYER:
{
if ( m_detectCollision && m_isActive )
{
CPlayer *player;
DVECTOR playerPos;
CRECT collisionArea;
// Only interested in SBs feet colliding with the box (pkg)
player=(CPlayer*)_thisThing;
playerPos=player->getPos();
collisionArea=getCollisionArea();
if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&&
playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2)
{
if ( ( m_reversed && playerPos.vx <= Pos.vx ) || ( !m_reversed && playerPos.vx >= Pos.vx ) )
{
player->setPlatform( this );
if(getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy)==0)
{
m_contact = true;
}
}
}
}
break;
}
case TYPE_HAZARD:
break;
default:
ASSERT(0);
break;
}
}*/
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::processMovement( int _frames )
{
s16 newAngle = getCollisionAngle();
if ( m_contact )
{
//if ( ( m_reversed && newAngle < -256 ) || newAngle > 256 )
//{
// flick player upwards
//GameScene.getPlayer()->springPlayerUp();
//}
CPlayer *player = GameScene.getPlayer();
if ( m_reversed )
@ -287,7 +234,7 @@ sBBox & CNpcBranchPlatform::getBBox()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcBranchPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, int offsetY)
/*int CNpcBranchPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, int offsetY)
{
DVECTOR top;
int angle;
@ -321,4 +268,4 @@ int CNpcBranchPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offse
return( ( top.vy - _y ) + angleHeight );
}
}
}*/

View File

@ -23,7 +23,7 @@ class CNpcBranchPlatform : public CNpcPlatform
public:
virtual void postInit();
virtual void render();
virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0);
//virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0);
protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames );

View File

@ -32,7 +32,10 @@
void CNpcFishHookPlatform::postInit()
{
CNpcPlatform::postInit();
sBBox boundingBox = m_modelGfx->GetBBox();
boundingBox.YMin += 18;
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
m_isMoving = false;
m_isResetting = false;

View File

@ -359,6 +359,18 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_FISH_HOOK_3_PLATFORM
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_PLAYER_BUBBLE_PLATFORM
3,
128,
@ -412,6 +424,7 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF
NPC_BIG_WHEEL_PLATFORM,
NPC_STEERABLE_BARREL_PLATFORM,
NPC_JELLYFISH_PLATFORM,
NPC_FISH_HOOK_3_PLATFORM,
NPC_PLAYER_BUBBLE_PLATFORM,
NPC_CLAM_PLATFORM,
};

View File

@ -143,6 +143,10 @@
#include "platform\pjellfsh.h"
#endif
#ifndef __PLATFORM_PFISHHK3_H__
#include "platform\pfishhk3.h"
#endif
#include "fx\fx.h"
#include "fx\fxjfish.h"
@ -334,6 +338,12 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform)
break;
}
case NPC_FISH_HOOK_3_PLATFORM:
{
platform = new ("fish hook 3 platform") CNpcFishHook3Platform;
break;
}
default:
{
ASSERT( 0 );
@ -429,6 +439,7 @@ void CNpcPlatform::init()
m_tiltAngle = 0;
m_tiltVelocity = 0;
m_tiltable = false;
m_initRotation = 0;
m_layerCollision = NULL;
@ -486,40 +497,29 @@ void CNpcPlatform::reinit()
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::calculateNonRotatedCollisionData()
{
DVECTOR collisionSize = getCollisionSize();
DVECTOR collisionOffset = getCollisionCentreOffset();
m_nonRotatedCollisionArea.XMax = ( collisionSize.vx >> 1 ) + collisionOffset.vx;
m_nonRotatedCollisionArea.XMin = -( collisionSize.vx >> 1 ) + collisionOffset.vx;
m_nonRotatedCollisionArea.YMax = ( collisionSize.vy >> 1 ) + collisionOffset.vy;
m_nonRotatedCollisionArea.YMin = -( collisionSize.vy >> 1 ) + collisionOffset.vy;
m_nonRotatedCollisionOffset = collisionOffset;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::postInit()
{
sBBox boundingBox = m_modelGfx->GetBBox();
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
/*if ( m_type == NPC_LINEAR_PLATFORM )
{
switch( CLevel::getCurrentChapter() )
{
case 5:
{
if ( CLevel::getCurrentChapterLevel() == 4 )
{
return;
}
break;
}
case 6:
{
if ( CLevel::getCurrentChapterLevel() == 1 )
{
return;
}
break;
}
}
// CFXJellyFishLegs *T=(CFXJellyFishLegs*)CFX::Create(CFX::FX_TYPE_JELLYFISH_LEGS,this);
// T->SetUp(64,4,8,8);
}*/
calculateNonRotatedCollisionData();
setCollisionAngle( m_tiltAngle >> 8 );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -651,74 +651,15 @@ void CNpcPlatform::setCollisionAngle(int newAngle)
shove.vx = 0;
shove.vy = getHeightFromPlatformAtPosition( playerPos.vx, playerPos.vy );
player->shove(shove);
/*if(getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy)==0)
{
// Ok.. currently stood on the platform - awkward bastard
DVECTOR centre;
int x,y;
DVECTOR shove;
// Rotate backwards to find x position on platform
centre=getCollisionCentre();
x=-((centre.vx-playerPos.vx)*mcos(-getCollisionAngle()&4095)>>(12));
// Rotate forwards to find new position *after* the platform has been rotated
y=x*msin(newAngle&4095)>>(12);
x=x*mcos(newAngle&4095)>>(12);
// Shove the player to the new position
shove.vx=0;//(x+centre.vx)-playerPos.vx; pkg - can't get this to work :(
shove.vy=(y+centre.vy)-playerPos.vy;
// Finally, to cope with any innacuracies that have been introduced, we run this
// new position through the getHeightFromPlatformAtPosition() code and use this to
// make sure that the player is still on the platform
playerPos.vx+=shove.vx;
playerPos.vy+=shove.vy;
y=(centre.vy-playerPos.vy)+((centre.vx-playerPos.vx)*msin(-newAngle&4095)>>12);
if(y)
{
shove.vy+=y;
}
player->shove(shove);
}*/
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcPlatform::calculateBoundingBoxSize()
{
/*int angle;
DVECTOR centre;
int halfLength;
int x1,y1,x2,y2;
angle=getCollisionAngle();
centre=getCollisionCentre();
//halfLength=m_platformWidth/2;
sBBox boundingBox = m_modelGfx->GetBBox();
halfLength = ( boundingBox.XMax - boundingBox.XMin ) >> 1;
x1=-halfLength*mcos(angle&4095)>>12;
y1=-halfLength*msin(angle&4095)>>12;
x2=+halfLength*mcos(angle&4095)>>12;
y2=+halfLength*msin(angle&4095)>>12;
setCollisionSize( abs(x2-x1), abs(y2-y1) );
//sBBox boundingBox = m_modelGfx->GetBBox();
//setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
//setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );*/
//sBBox boundingBox = m_modelGfx->GetBBox();
sBBox boundingBox = getBBox();
//sBBox boundingBox = getBBox();
sBBox boundingBox = m_nonRotatedCollisionArea;
// 'render' collision box at correct angle
@ -739,7 +680,7 @@ void CNpcPlatform::calculateBoundingBoxSize()
MATRIX mtx;
SetIdentNoTrans(&mtx );
RotMatrixZ( getCollisionAngle(), &mtx );
RotMatrixZ( getCollisionAngle() + m_initRotation, &mtx );
int i;
@ -748,6 +689,14 @@ void CNpcPlatform::calculateBoundingBoxSize()
ApplyMatrix( &mtx, &testPointsNonRel[i], &testPoints[i] );
}
SVECTOR offsetSource;
VECTOR offsetTarget;
offsetSource.vx = m_nonRotatedCollisionOffset.vx;
offsetSource.vy = m_nonRotatedCollisionOffset.vy;
ApplyMatrix( &mtx, &offsetSource, &offsetTarget );
int x1, x2, y1, y2;
x1 = x2 = testPoints[0].vx;
@ -775,6 +724,8 @@ void CNpcPlatform::calculateBoundingBoxSize()
}
setCollisionSize( x2 - x1 + 1, y2 - y1 + 1 );
setCollisionCentreOffset( offsetTarget.vx, offsetTarget.vy );
}
@ -1076,10 +1027,9 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in
CRECT collisionArea = getCollisionArea();
sBBox boundingBox = getBBox();
top.vy = offsetY + collisionArea.y1;
angle=getCollisionAngle();
angle=getCollisionAngle() + m_initRotation;
if(angle==0)
{
// Non-rotated platform

View File

@ -80,6 +80,7 @@ public:
NPC_BIG_WHEEL_PLATFORM,
NPC_STEERABLE_BARREL_PLATFORM,
NPC_JELLYFISH_PLATFORM,
NPC_FISH_HOOK_3_PLATFORM,
NPC_PLAYER_BUBBLE_PLATFORM,
NPC_CLAM_PLATFORM,
NPC_PLATFORM_TYPE_MAX,
@ -201,12 +202,16 @@ protected:
s32 m_tiltVelocity;
bool m_extendDir;
s16 m_speed;
s16 m_initRotation;
CModelGfx *m_modelGfx;
u8 m_isShuttingDown;
int m_graphicNum;
sBBox m_nonRotatedCollisionArea;
DVECTOR m_nonRotatedCollisionOffset;
virtual void collidedWith(CThing *_thisThing);
static NPC_PLATFORM_UNIT_TYPE mapEditConvertTable[NPC_PLATFORM_TYPE_MAX];
@ -215,6 +220,7 @@ protected:
protected:
virtual void setCollisionAngle(int newAngle); // Actually.. this probly doesn't need to be in the base calss anymore.. :/
virtual void calculateNonRotatedCollisionData();
virtual void calculateBoundingBoxSize();

View File

@ -31,7 +31,10 @@
void CNpcPendulumPlatform::postInit()
{
CNpcPlatform::postInit();
sBBox boundingBox = m_modelGfx->GetBBox();
boundingBox.YMin += 18;
setCollisionSize( ( boundingBox.XMax - boundingBox.XMin ), ( boundingBox.YMax - boundingBox.YMin ) );
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
m_extendDir = EXTEND_LEFT;
m_extension = 0;

View File

@ -83,7 +83,7 @@ Jellyfish=25
Industrial=1
Leaf=2
FishHook1=5
FishHook2=5
FishHook2=26
SwingingFishHook=10
BendyBranchLeft=11
BendyBranchRight=11

View File

@ -1317,6 +1317,14 @@ SOURCE=..\..\..\source\platform\pfishhk.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfishhk3.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pfishhk3.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\platform\pgeyser.cpp
# End Source File
# Begin Source File