This commit is contained in:
parent
1d003cfe33
commit
beaa0247f1
2 changed files with 95 additions and 0 deletions
66
source/platform/pcart.cpp
Normal file
66
source/platform/pcart.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pcart.cpp
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PCART_H__
|
||||||
|
#include "platform\pcart.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcCartPlatform::postInit()
|
||||||
|
{
|
||||||
|
m_npcPath.setPathType( CNpcPath::PONG_PATH );
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void CNpcCartPlatform::processMovement( int _frames )
|
||||||
|
{
|
||||||
|
s32 fallSpeed = 3;
|
||||||
|
s8 yMovement = fallSpeed * _frames;
|
||||||
|
s32 distX, distY, heading;
|
||||||
|
s32 groundHeight;
|
||||||
|
s32 moveX = 0;
|
||||||
|
s32 moveY = 0;
|
||||||
|
|
||||||
|
bool pathComplete;
|
||||||
|
|
||||||
|
m_npcPath.thinkFlat( Pos, &pathComplete, &distX, &distY, &heading );
|
||||||
|
|
||||||
|
moveX = m_data[m_type].speed * _frames;
|
||||||
|
|
||||||
|
if ( heading == 2048 )
|
||||||
|
{
|
||||||
|
moveX = -moveX;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check for vertical movement
|
||||||
|
|
||||||
|
groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 );
|
||||||
|
|
||||||
|
if ( groundHeight <= yMovement )
|
||||||
|
{
|
||||||
|
// groundHeight <= yMovement indicates either just above ground or on or below ground
|
||||||
|
|
||||||
|
moveY = groundHeight;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// fall
|
||||||
|
|
||||||
|
moveY = yMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
|
}
|
29
source/platform/pcart.h
Normal file
29
source/platform/pcart.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pcart.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PCART_H__
|
||||||
|
#define __PLATFORM_PCART_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcCartPlatform : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void postInit();
|
||||||
|
protected:
|
||||||
|
virtual void processMovement( int _frames );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Add a link
Reference in a new issue