SBSPSS/source/platform/pfallnor.cpp

88 lines
2.0 KiB
C++
Raw Normal View History

2001-05-03 21:01:23 +02:00
/*=========================================================================
pfallnor.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFALLNOR_H__
#include "platform\pfallnor.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingNoRespawnPlatform::postInit()
{
2001-05-05 15:54:34 +02:00
CNpcPlatform::postInit();
2001-05-03 21:01:23 +02:00
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingNoRespawnPlatform::processMovement( int _frames )
{
s32 moveX, moveY;
s32 distX, distY, heading;
bool pathComplete;
m_npcPath.thinkVertical( Pos, &pathComplete, &distX, &distY, &heading );
if ( pathComplete )
{
setToShutdown();
}
else
{
moveX = 0;
2001-05-09 23:27:23 +02:00
moveY = m_speed * _frames;
2001-05-03 21:01:23 +02:00
if ( heading == 3072 )
{
moveY = -moveY;
}
2001-05-25 20:43:47 +02:00
s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
2001-05-03 21:01:23 +02:00
if ( groundHeight < moveY )
{
2001-05-29 17:29:56 +02:00
if ( ( CGameScene::getCollision()->getCollisionBlock( Pos.vx, Pos.vy + groundHeight + 8 ) & COLLISION_TYPE_MASK ) != COLLISION_TYPE_FLAG_DEATH )
2001-05-08 17:35:37 +02:00
{
moveY = groundHeight;
moveX = 2 * _frames;
}
2001-05-03 21:01:23 +02:00
}
Pos.vx += moveX;
Pos.vy += moveY;
}
2001-05-22 23:42:39 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CRECT *CNpcFallingNoRespawnPlatform::getThinkBBox()
{
CRECT objThinkBox = getCollisionArea();
sBBox &thinkBBox = CThingManager::getThinkBBox();
objThinkBox.x1 = thinkBBox.XMin;
objThinkBox.x2 = thinkBBox.XMax;
objThinkBox.y1 = thinkBBox.YMin;
objThinkBox.y2 = thinkBBox.YMax;
return &objThinkBox;
2001-05-03 21:01:23 +02:00
}