This commit is contained in:
parent
2ed74c834b
commit
1d003cfe33
2 changed files with 91 additions and 0 deletions
62
source/platform/pfalling.cpp
Normal file
62
source/platform/pfalling.cpp
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pfalling.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PFALLING_H__
|
||||||
|
#include "platform\pfalling.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcFallingPlatform::postInit()
|
||||||
|
{
|
||||||
|
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcFallingPlatform::processMovement( int _frames )
|
||||||
|
{
|
||||||
|
s32 moveX, moveY;
|
||||||
|
s32 distX, distY, heading;
|
||||||
|
bool pathComplete;
|
||||||
|
|
||||||
|
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
|
||||||
|
|
||||||
|
if ( pathComplete )
|
||||||
|
{
|
||||||
|
m_isActive = false;
|
||||||
|
m_timer = 4 * GameState::getOneSecondInFrames();
|
||||||
|
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
moveX = 0;
|
||||||
|
moveY = m_data[m_type].speed * _frames;
|
||||||
|
|
||||||
|
if ( heading == 3072 )
|
||||||
|
{
|
||||||
|
moveY = -moveY;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
||||||
|
|
||||||
|
if ( groundHeight < moveY )
|
||||||
|
{
|
||||||
|
moveY = groundHeight;
|
||||||
|
moveX = 2 * _frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
|
}
|
||||||
|
}
|
29
source/platform/pfalling.h
Normal file
29
source/platform/pfalling.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pfalling.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PFALLING_H__
|
||||||
|
#define __PLATFORM_PFALLING_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcFallingPlatform : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void postInit();
|
||||||
|
protected:
|
||||||
|
virtual void processMovement( int _frames );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue