This commit is contained in:
Charles 2001-04-25 19:22:15 +00:00
parent 4d5777fee4
commit 22c46c193a
8 changed files with 122 additions and 74 deletions

View file

@ -15,89 +15,110 @@
#include "platform\pbranch.h" #include "platform\pbranch.h"
#endif #endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::postInit() void CNpcBranchPlatform::postInit()
{ {
m_state = NPC_BRANCH_STOP; m_angularVelocity = 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::setWaypoints( sThingPlatform *ThisPlatform )
{
int pointNum;
u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform));
u16 initXPos, newXPos, newYPos;
initXPos = newXPos = (u16) *PntList;
PntList++;
newYPos = (u16) *PntList;
PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4;
init( startPos );
if ( ThisPlatform->PointCount > 1 )
{
newXPos = (u16) *PntList;
if ( newXPos < initXPos )
{
m_reversed = true;
}
else
{
m_reversed = false;
}
}
else
{
m_reversed = false;
}
} }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBranchPlatform::processMovement( int _frames ) void CNpcBranchPlatform::processMovement( int _frames )
{ {
s16 tilt; s16 newAngle = getCollisionAngle();
s16 maxTilt = 3 * _frames;
switch( m_state ) if ( m_contact )
{ {
case NPC_BRANCH_STOP: if ( ( m_reversed && newAngle < -256 ) || newAngle > 256 )
{ {
if ( m_contact ) // flick player upwards
{
m_state = NPC_BRANCH_DIP;
}
else
{
if ( getCollisionAngle() )
{
// go to zero bend
tilt = -getCollisionAngle();
if ( tilt > maxTilt )
{
tilt = maxTilt;
}
else if ( tilt < -maxTilt )
{
tilt = -maxTilt;
}
setCollisionAngle( getCollisionAngle() + tilt );
}
}
break;
} }
case NPC_BRANCH_DIP: s16 angularForce = 3 * _frames;
if ( m_reversed )
{ {
if ( m_contact ) angularForce = -angularForce;
{
// bend
tilt = 3 * _frames;
s16 newAngle = getCollisionAngle() + tilt;
if ( newAngle > 256 )
{
// if bent beyond certain limit, spring
m_state = NPC_BRANCH_SPRING;
}
setCollisionAngle( newAngle );
}
else
{
m_state = NPC_BRANCH_STOP;
}
break;
} }
case NPC_BRANCH_SPRING: m_angularVelocity += angularForce;
{
if ( m_contact )
{
// spring off player
}
m_state = NPC_BRANCH_STOP;
break;
}
} }
s32 resistance = -( 10 * newAngle ) >> 8;
if ( newAngle > 0 && resistance > -2 )
{
resistance = -2;
}
else if ( newAngle < 0 && resistance < 2 )
{
resistance = 2;
}
// get direction of resistance
m_angularVelocity += resistance;
newAngle += m_angularVelocity;
if ( m_angularVelocity )
{
m_angularVelocity += -m_angularVelocity / abs( m_angularVelocity );
}
/*if ( newAngle > 320 )
{
newAngle = 320;
}
else if ( newAngle < -320 )
{
newAngle = -320;
}*/
setCollisionAngle( newAngle );
} }

View file

@ -23,14 +23,11 @@ class CNpcBranchPlatform : public CNpcPlatform
public: public:
virtual void postInit(); virtual void postInit();
protected: protected:
virtual void setWaypoints( sThingPlatform *ThisPlatform );
virtual void processMovement( int _frames ); virtual void processMovement( int _frames );
enum NPC_BRANCH_STATE s32 m_angularVelocity;
{ u8 m_reversed;
NPC_BRANCH_STOP = 0,
NPC_BRANCH_DIP = 1,
NPC_BRANCH_SPRING,
};
}; };
#endif #endif

View file

@ -176,6 +176,20 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] =
NPC_PLATFORM_TIMER_NONE, NPC_PLATFORM_TIMER_NONE,
}, },
{ // NPC_BRANCH_PLATFORM
ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP,
3,
128,
true,
DAMAGE__NONE,
0,
4,
NPC_PLATFORM_INFINITE_LIFE,
0,
NPC_PLATFORM_TIMER_NONE,
},
{ // NPC_PLAYER_BUBBLE_PLATFORM { // NPC_PLAYER_BUBBLE_PLATFORM
ACTORS_CLAM_SBK, ACTORS_CLAM_SBK,
ANIM_CLAM_SIDESNAP, ANIM_CLAM_SIDESNAP,
@ -204,5 +218,6 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF
NPC_BOBBING_PLATFORM, NPC_BOBBING_PLATFORM,
NPC_CART_PLATFORM, NPC_CART_PLATFORM,
NPC_FISH_HOOK_2_PLATFORM, NPC_FISH_HOOK_2_PLATFORM,
NPC_BRANCH_PLATFORM,
NPC_PLAYER_BUBBLE_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM,
}; };

View file

@ -83,6 +83,10 @@
#include "platform\ppendulm.h" #include "platform\ppendulm.h"
#endif #endif
#ifndef __PLATFORM_PBRANCH_H__
#include "platform\pbranch.h"
#endif
#ifndef __PLATFORM_PPLAYER_H__ #ifndef __PLATFORM_PPLAYER_H__
#include "platform\pplayer.h" #include "platform\pplayer.h"
#endif #endif
@ -161,6 +165,12 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform)
break; break;
} }
case NPC_BRANCH_PLATFORM:
{
platform = new ("branch platform") CNpcBranchPlatform;
break;
}
default: default:
{ {
ASSERT( 0 ); ASSERT( 0 );

View file

@ -53,6 +53,7 @@ public:
NPC_FALLING_PLATFORM, NPC_FALLING_PLATFORM,
NPC_CART_PLATFORM, NPC_CART_PLATFORM,
NPC_FISH_HOOK_2_PLATFORM, NPC_FISH_HOOK_2_PLATFORM,
NPC_BRANCH_PLATFORM,
NPC_PLAYER_BUBBLE_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM,
NPC_PLATFORM_TYPE_MAX, NPC_PLATFORM_TYPE_MAX,
}; };

View file

@ -30,8 +30,6 @@ void CNpcPendulumPlatform::postInit()
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DVECTOR startPos;
DVECTOR pivotPos;
void CNpcPendulumPlatform::setWaypoints( sThingPlatform *ThisPlatform ) void CNpcPendulumPlatform::setWaypoints( sThingPlatform *ThisPlatform )
{ {
int pointNum; int pointNum;
@ -45,6 +43,7 @@ void CNpcPendulumPlatform::setWaypoints( sThingPlatform *ThisPlatform )
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
DVECTOR startPos;
startPos.vx = newXPos << 4; startPos.vx = newXPos << 4;
startPos.vy = newYPos << 4; startPos.vy = newYPos << 4;
@ -55,6 +54,7 @@ void CNpcPendulumPlatform::setWaypoints( sThingPlatform *ThisPlatform )
newYPos = (u16) *PntList; newYPos = (u16) *PntList;
PntList++; PntList++;
DVECTOR pivotPos;
pivotPos.vx = newXPos << 4; pivotPos.vx = newXPos << 4;
pivotPos.vy = newYPos << 4; pivotPos.vy = newYPos << 4;

View file

@ -83,6 +83,7 @@ Leaf=2
FishHook1=5 FishHook1=5
FishHook2=5 FishHook2=5
SwingingFishHook=10 SwingingFishHook=10
BendyBranch=11
################################################ ################################################
# Triggers # Triggers

View file

@ -26,3 +26,6 @@ Gfx=..\..\Graphics\platforms\FishHook2\FishHook2.gin
[SwingingFishHook] [SwingingFishHook]
Gfx=..\..\Graphics\platforms\FishHook3\FishHook3.gin Gfx=..\..\Graphics\platforms\FishHook3\FishHook3.gin
[BendyBranch]
Gfx=..\..\Graphics\platforms\Bendybranch\bendybranch.gin