This commit is contained in:
Charles 2001-07-05 20:07:49 +00:00
parent 74f055d6d9
commit 5dca926fb0
2 changed files with 137 additions and 0 deletions

102
source/platform/pfblock.cpp Normal file
View file

@ -0,0 +1,102 @@
/*=========================================================================
pfblock.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFBLOCK_H__
#include "platform\pfblock.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __VID_HEADER_
#include "system\vid.h"
#endif
#ifndef __UTILS_HEADER__
#include "utils\utils.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingBlockPlatform::postInit()
{
CNpcPlatform::postInit();
m_isTriggered = false;
m_isFalling = false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcFallingBlockPlatform::processMovement( int _frames )
{
if ( m_isTriggered )
{
if ( m_timer > 0 )
{
m_timer -= _frames;
if ( m_timer <= 0 )
{
Pos = m_base;
m_isFalling = true;
}
else
{
Pos.vx = m_base.vx + ( -3 + ( getRnd() % 7 ) );
Pos.vy = m_base.vy + ( -3 + ( getRnd() % 7 ) );
if ( m_soundId == NOT_PLAYING )
{
m_soundId = (int) CSoundMediator::playSfx( CSoundMediator::SFX_HAZARD__STALACTITE_RATTLE, true );
}
}
}
else
{
DVECTOR offset = CLevel::getCameraPos();
s32 yPos = Pos.vy - offset.vy;
if ( yPos > VidGetScrH() )
{
setToShutdown();
}
s32 moveY = m_speed * _frames;
Pos.vy += moveY;
}
}
else if ( m_contact )
{
m_isTriggered = true;
m_timer = GameState::getOneSecondInFrames();
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CNpcFallingBlockPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
{
if ( m_isFalling )
{
return( false );
}
else
{
return( CNpcPlatform::checkCollisionAgainst( _thisThing, _frames ) );
}
}

35
source/platform/pfblock.h Normal file
View file

@ -0,0 +1,35 @@
/*=========================================================================
pfblock.h
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PFBLOCK_H__
#define __PLATFORM_PFBLOCK_H__
#ifndef __PLATFORM_PLATFORM_H__
#include "platform\platform.h"
#endif
class CNpcFallingBlockPlatform : public CNpcPlatform
{
public:
void postInit();
CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );}
int checkCollisionAgainst(CThing *_thisThing, int _frames);
protected:
void processMovement( int _frames );
u8 m_isTriggered;
u8 m_isFalling;
s32 m_timer;
};
#endif