This commit is contained in:
parent
af8fa3eca2
commit
f1091bc85c
4 changed files with 235 additions and 0 deletions
68
source/platform/pfallnor.cpp
Normal file
68
source/platform/pfallnor.cpp
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
moveY = m_data[m_type].speed * _frames;
|
||||||
|
|
||||||
|
if ( heading == 3072 )
|
||||||
|
{
|
||||||
|
moveY = -moveY;
|
||||||
|
}
|
||||||
|
|
||||||
|
s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 );
|
||||||
|
|
||||||
|
if ( groundHeight < moveY )
|
||||||
|
{
|
||||||
|
moveY = groundHeight;
|
||||||
|
moveX = 2 * _frames;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pos.vx += moveX;
|
||||||
|
Pos.vy += moveY;
|
||||||
|
}
|
||||||
|
}
|
29
source/platform/pfallnor.h
Normal file
29
source/platform/pfallnor.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pfallnor.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PFALLNOR_H__
|
||||||
|
#define __PLATFORM_PFALLNOR_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcFallingNoRespawnPlatform : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void postInit();
|
||||||
|
protected:
|
||||||
|
virtual void processMovement( int _frames );
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
105
source/platform/pfgen.cpp
Normal file
105
source/platform/pfgen.cpp
Normal file
|
@ -0,0 +1,105 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CNpcPlatform *newPlatform;
|
||||||
|
|
||||||
|
void CNpcFallingPlatformGenerator::think( int _frames )
|
||||||
|
{
|
||||||
|
/*m_timer -= _frames;
|
||||||
|
|
||||||
|
if ( m_timer < 0 )
|
||||||
|
{
|
||||||
|
m_timer = GameState::getOneSecondInFrames() + ( getRnd() * ( m_data[m_type].initTimer - 1 ) * GameState::getOneSecondInFrames() );
|
||||||
|
|
||||||
|
// generate new falling platform
|
||||||
|
|
||||||
|
newPlatform = NULL;
|
||||||
|
|
||||||
|
switch( m_targetType )
|
||||||
|
{
|
||||||
|
case NPC_OILDRUM_PLATFORM:
|
||||||
|
case NPC_CRATE_PLATFORM:
|
||||||
|
{
|
||||||
|
newPlatform = new ("falling platform") CNpcFallingNoRespawnPlatform;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
ASSERT( 0 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(newPlatform);
|
||||||
|
|
||||||
|
newPlatform->setType( m_targetType );
|
||||||
|
newPlatform->setGraphic( m_graphicNum );
|
||||||
|
|
||||||
|
//CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList();
|
||||||
|
|
||||||
|
//if ( sourceWaypoint )
|
||||||
|
{
|
||||||
|
DVECTOR startPos;
|
||||||
|
//startPos.vx = sourceWaypoint->pos.vx;
|
||||||
|
//startPos.vy = sourceWaypoint->pos.vy;
|
||||||
|
startPos.vx = 100;
|
||||||
|
startPos.vy = 100;
|
||||||
|
|
||||||
|
newPlatform->init( startPos );
|
||||||
|
ASSERT(m_layerCollision);
|
||||||
|
|
||||||
|
//while( sourceWaypoint )
|
||||||
|
//{
|
||||||
|
//newPlatform->addWaypoint( sourceWaypoint->pos.vx >> 4, sourceWaypoint->pos.vy >> 4 );
|
||||||
|
//sourceWaypoint = sourceWaypoint->nextWaypoint;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
newPlatform->setLayerCollision( m_layerCollision );
|
||||||
|
//platform->setTiltable( false );
|
||||||
|
//platform->postInit();
|
||||||
|
}*/
|
||||||
|
}
|
33
source/platform/pfgen.h
Normal file
33
source/platform/pfgen.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
/*=========================================================================
|
||||||
|
|
||||||
|
pfgen.h
|
||||||
|
|
||||||
|
Author: CRB
|
||||||
|
Created:
|
||||||
|
Project: Spongebob
|
||||||
|
Purpose:
|
||||||
|
|
||||||
|
Copyright (c) 2001 Climax Development Ltd
|
||||||
|
|
||||||
|
===========================================================================*/
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PFGEN_H__
|
||||||
|
#define __PLATFORM_PFGEN_H__
|
||||||
|
|
||||||
|
#ifndef __PLATFORM_PLATFORM_H__
|
||||||
|
#include "platform\platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class CNpcFallingPlatformGenerator : public CNpcPlatform
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void setTargetType( NPC_PLATFORM_UNIT_TYPE targetType ) {m_targetType = targetType;}
|
||||||
|
virtual void render();
|
||||||
|
protected:
|
||||||
|
virtual void think( int _frames );
|
||||||
|
virtual void collidedWith(CThing *_thisThing);
|
||||||
|
|
||||||
|
NPC_PLATFORM_UNIT_TYPE m_targetType;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
Loading…
Add table
Reference in a new issue