SBSPSS/source/platform/pfalling.cpp

76 lines
1.6 KiB
C++
Raw Normal View History

2001-04-23 20:46:15 +02:00
/*=========================================================================
pfalling.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFALLING_H__
#include "platform\pfalling.h"
#endif
2001-04-23 22:40:13 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
2001-05-01 16:36:14 +02:00
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
2001-04-23 20:46:15 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatform::postInit()
{
2001-05-05 15:54:34 +02:00
CNpcPlatform::postInit();
2001-04-23 20:46:15 +02:00
m_npcPath.setPathType( CNpcPath::SINGLE_USE_PATH );
2001-05-01 16:36:14 +02:00
m_isActive = false;
m_timer = 4 * GameState::getOneSecondInFrames();
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
2001-04-23 20:46:15 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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;
2001-05-01 16:36:14 +02:00
m_timer = getRnd() % ( 4 * GameState::getOneSecondInFrames() );
2001-04-23 20:46:15 +02:00
m_timerType = NPC_PLATFORM_TIMER_RESPAWN;
}
else
{
moveX = 0;
2001-05-09 23:27:23 +02:00
moveY = m_speed * _frames;
2001-04-23 20:46:15 +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-04-23 20:46:15 +02:00
if ( groundHeight < moveY )
{
moveY = groundHeight;
moveX = 2 * _frames;
}
Pos.vx += moveX;
Pos.vy += moveY;
}
}