This commit is contained in:
parent
63a628989a
commit
0b2e74caf7
2 changed files with 139 additions and 0 deletions
103
source/platform/pbranch.cpp
Normal file
103
source/platform/pbranch.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pbranch.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PBRANCH_H__
|
||||||
|
#include "platform\pbranch.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcBranchPlatform::postInit()
|
||||||
|
{
|
||||||
|
m_state = NPC_BRANCH_STOP;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcBranchPlatform::processMovement( int _frames )
|
||||||
|
{
|
||||||
|
s16 tilt;
|
||||||
|
s16 maxTilt = 3 * _frames;
|
||||||
|
|
||||||
|
switch( m_state )
|
||||||
|
{
|
||||||
|
case NPC_BRANCH_STOP:
|
||||||
|
{
|
||||||
|
if ( m_contact )
|
||||||
|
{
|
||||||
|
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:
|
||||||
|
{
|
||||||
|
if ( m_contact )
|
||||||
|
{
|
||||||
|
// 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:
|
||||||
|
{
|
||||||
|
if ( m_contact )
|
||||||
|
{
|
||||||
|
// spring off player
|
||||||
|
}
|
||||||
|
|
||||||
|
m_state = NPC_BRANCH_STOP;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
source/platform/pbranch.h
Normal file
36
source/platform/pbranch.h
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pbranch.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PBRANCH_H__
|
||||||
|
#define __PLATFORM_PBRANCH_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcBranchPlatform : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void postInit();
|
||||||
|
protected:
|
||||||
|
virtual void processMovement( int _frames );
|
||||||
|
|
||||||
|
enum NPC_BRANCH_STATE
|
||||||
|
{
|
||||||
|
NPC_BRANCH_STOP = 0,
|
||||||
|
NPC_BRANCH_DIP = 1,
|
||||||
|
NPC_BRANCH_SPRING,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue