SBSPSS/source/platform/pfgen.cpp

106 lines
2.3 KiB
C++
Raw Normal View History

2001-05-03 21:01:23 +02:00
/*=========================================================================
pfgen.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFGEN_H__
#include "platform\pfgen.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __PLATFORM_PFALLNOR_H__
#include "platform\pfallnor.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::collidedWith(CThing *_thisThing)
{
// do nothing
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::render()
{
// no rendering
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingPlatformGenerator::think( int _frames )
{
2001-05-03 21:44:00 +02:00
m_timer -= _frames;
2001-05-03 21:01:23 +02:00
if ( m_timer < 0 )
{
2001-05-10 18:47:35 +02:00
m_timer = ( 3 * GameState::getOneSecondInFrames() ) + ( getRnd() % ( ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() ) );
2001-05-03 21:01:23 +02:00
// generate new falling platform
2001-05-03 21:44:00 +02:00
CNpcPlatform *newPlatform;
2001-05-03 21:01:23 +02:00
newPlatform = NULL;
switch( m_targetType )
{
case NPC_OILDRUM_PLATFORM:
case NPC_CRATE_PLATFORM:
2001-05-04 18:47:09 +02:00
case NPC_VERTICAL_OILDRUM_PLATFORM:
2001-05-03 21:01:23 +02:00
{
newPlatform = new ("falling platform") CNpcFallingNoRespawnPlatform;
break;
}
default:
{
ASSERT( 0 );
break;
}
}
ASSERT(newPlatform);
newPlatform->setType( m_targetType );
newPlatform->setGraphic( m_graphicNum );
2001-05-03 21:44:00 +02:00
CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList();
2001-05-03 21:01:23 +02:00
2001-05-03 21:44:00 +02:00
if ( sourceWaypoint )
2001-05-03 21:01:23 +02:00
{
DVECTOR startPos;
2001-05-03 21:44:00 +02:00
startPos.vx = sourceWaypoint->pos.vx;
startPos.vy = sourceWaypoint->pos.vy;
//startPos.vx = 100;
//startPos.vy = 100;
2001-05-03 21:01:23 +02:00
newPlatform->init( startPos );
ASSERT(m_layerCollision);
2001-05-03 21:44:00 +02:00
while( sourceWaypoint )
{
newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
sourceWaypoint = sourceWaypoint->nextWaypoint;
}
2001-05-03 21:01:23 +02:00
}
newPlatform->setLayerCollision( m_layerCollision );
2001-05-03 21:44:00 +02:00
newPlatform->setTiltable( false );
newPlatform->postInit();
}
2001-05-03 21:01:23 +02:00
}