From 2d65d44406607335a1da9944adffda74e5ae5556 Mon Sep 17 00:00:00 2001 From: Charles Date: Fri, 8 Jun 2001 14:33:43 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/platform/platdata.cpp | 13 ++ source/platform/platform.cpp | 10 + source/platform/platform.h | 1 + source/platform/psbarrel.cpp | 4 +- source/platform/psoil.cpp | 181 ++++++++++++++++++ source/platform/psoil.h | 27 +++ tools/Data/bin/MkLevel.ini | 2 +- .../spongebob project/spongebob project.dsp | 8 + 9 files changed, 245 insertions(+), 4 deletions(-) create mode 100644 source/platform/psoil.cpp create mode 100644 source/platform/psoil.h diff --git a/makefile.gaz b/makefile.gaz index 6de6a050f..d22d9bad3 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -133,7 +133,8 @@ platform_src := platform \ pdrop \ psswitch \ plift \ - plurve + plurve \ + psoil hazard_src := hazard \ hfalling \ diff --git a/source/platform/platdata.cpp b/source/platform/platdata.cpp index ab7470b60..d1a1e1318 100644 --- a/source/platform/platdata.cpp +++ b/source/platform/platdata.cpp @@ -514,6 +514,18 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] = 2, NPC_PLATFORM_TIMER_NONE, }, + + { // NPC_STEERABLE_OILDRUM_PLATFORM + 3, + 128, + true, + DAMAGE__NONE, + 0, + 4, + NPC_PLATFORM_INFINITE_LIFE, + 0, + NPC_PLATFORM_TIMER_NONE, + }, }; CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATFORM_TYPE_MAX] = @@ -554,6 +566,7 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF NPC_STEAM_SWITCH_PLATFORM, NPC_LIFT_PLATFORM, NPC_LOVE_BOAT_PLATFORM, + NPC_STEERABLE_OILDRUM_PLATFORM, NPC_CONVEYOR_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, NPC_CLAM_PLATFORM, diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 18db18757..827500518 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -187,6 +187,10 @@ #include "platform\plurve.h" #endif +#ifndef __PLATFORM_PSOIL_H__ +#include "platform\psoil.h" +#endif + #include "fx\fx.h" #include "fx\fxjfish.h" @@ -431,6 +435,12 @@ CNpcPlatform *CNpcPlatform::Create(int Type) break; } + case NPC_STEERABLE_OILDRUM_PLATFORM: + { + platform = new ("steerable oildrum platform") CNpcSteerableOildrumPlatform; + break; + } + default: { ASSERT( 0 ); diff --git a/source/platform/platform.h b/source/platform/platform.h index ca9fa7151..9070db7bf 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -93,6 +93,7 @@ public: NPC_STEAM_SWITCH_PLATFORM, NPC_LIFT_PLATFORM, NPC_LOVE_BOAT_PLATFORM, + NPC_STEERABLE_OILDRUM_PLATFORM, NPC_PLATFORM_TYPE_MAX, }; enum diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index a11dddc89..28927fba7 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -134,7 +134,7 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) // check for collision - if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + 14 ) < -maxHeight ) { moveX = 0; m_currentSpeed = 0; @@ -153,7 +153,7 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) // check for vertical movement - groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + 14, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/platform/psoil.cpp b/source/platform/psoil.cpp new file mode 100644 index 000000000..fb3228d91 --- /dev/null +++ b/source/platform/psoil.cpp @@ -0,0 +1,181 @@ +/*========================================================================= + + psoil.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PSOIL_H__ +#include "platform\psoil.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 CNpcSteerableOildrumPlatform::processMovement( int _frames ) +{ + s32 maxHeight = 20; + s32 fallSpeed = 3; + s8 yMovement = fallSpeed * _frames; + s32 groundHeight; + + s32 moveX = 0; + s32 moveY = 0; + + CPlayer *player = GameScene.getPlayer(); + + if ( m_contact ) + { + DVECTOR playerPos = player->getPos(); + + DVECTOR *playerVel = player->getMoveVelocity(); + + /*s32 speedChange = -playerVel->vx << 8; + + if ( speedChange > ( _frames << 5 ) ) + { + speedChange = _frames << 5; + } + else if ( speedChange < -( _frames << 5 ) ) + { + speedChange = -_frames << 5; + } + + m_currentSpeed += speedChange; + + if ( m_currentSpeed > ( m_speed << 8 ) ) + { + m_currentSpeed = ( m_speed << 8 ); + } + else if ( m_currentSpeed < -( m_speed << 8 ) ) + { + m_currentSpeed = -( m_speed << 8 ); + }*/ + + m_currentSpeed = -playerVel->vx << 4; + + /*s32 playerX = playerPos.vx - this->Pos.vx; + + if ( playerX > 5 ) + { + // increase barrel speed to right + + m_currentSpeed += _frames << 2; + + if ( m_currentSpeed > ( m_speed << 8 ) ) + { + m_currentSpeed = ( m_speed << 8 ); + } + } + else if ( playerX < -5 ) + { + m_currentSpeed -= _frames << 2; + + if ( m_currentSpeed < -( m_speed << 8 ) ) + { + m_currentSpeed = -( m_speed << 8 ); + } + }*/ + } + else + { + // reduce speed + + /*s32 speedReduce = -m_currentSpeed; + + if ( speedReduce > _frames ) + { + speedReduce = _frames; + } + else if ( speedReduce < -_frames ) + { + speedReduce = -_frames; + } + + m_currentSpeed += speedReduce;*/ + + m_currentSpeed = 0; + } + + /*m_moveXHighRes += m_currentSpeed * _frames; + + moveX = m_moveXHighRes >> 8; + m_moveXHighRes -= moveX << 8;*/ + + moveX = ( m_currentSpeed * _frames ) >> 8; + + // check for collision + + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + 20 ) < -maxHeight ) + { + moveX = 0; + m_currentSpeed = 0; + } + + m_rotation += ( m_currentSpeed * 30 * _frames ) >> 10; + m_rotation &= 4095; + + if ( m_contact ) + { + DVECTOR shove; + shove.vx = moveX; + shove.vy = 0; + player->shove(shove); + } + + // check for vertical movement + + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + 20, yMovement + 16 ); + + if ( groundHeight <= yMovement ) + { + // groundHeight <= yMovement indicates either just above ground or on or below ground + + moveY = groundHeight; + } + else + { + // fall + + moveY = yMovement; + } + + Pos.vx += moveX; + Pos.vy += moveY; + + s32 minX, maxX; + + m_npcPath.getPathXExtents( &minX, &maxX ); + + if ( minX != maxX ) + { + if ( Pos.vx < minX ) + { + Pos.vx = minX; + m_currentSpeed = 0; + } + else if ( Pos.vx > maxX ) + { + Pos.vx = maxX; + m_currentSpeed = 0; + } + } +} \ No newline at end of file diff --git a/source/platform/psoil.h b/source/platform/psoil.h new file mode 100644 index 000000000..598a1f1e3 --- /dev/null +++ b/source/platform/psoil.h @@ -0,0 +1,27 @@ +/*========================================================================= + + psoil.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PSOIL_H__ +#define __PLATFORM_PSOIL_H__ + +#ifndef __PLATFORM_PSBARREL_H__ +#include "platform\psbarrel.h" +#endif + +class CNpcSteerableOildrumPlatform : public CNpcSteerableBarrelPlatform +{ +protected: + virtual void processMovement( int _frames ); +}; + +#endif \ No newline at end of file diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index dcae6ddde..85daced0e 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -110,7 +110,7 @@ FixedPathBarrelPlatform=1 SteerableBarrelPlatform=24 RockGeyser=7 Retracting=6 -RollingOildrumPlatform=24 +RollingOildrumPlatform=36 RisingBridge=27 BalloonBridge=28 TrapdoorLeft=29 diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index 1b69b28ea..c4658b64d 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1645,6 +1645,14 @@ SOURCE=..\..\..\source\platform\pseesaw.h # End Source File # Begin Source File +SOURCE=..\..\..\source\platform\psoil.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\platform\psoil.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\platform\psswitch.cpp # End Source File # Begin Source File