diff --git a/makefile.gaz b/makefile.gaz index 713f3226f..a8c855acb 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -122,7 +122,8 @@ platform_src := platform \ psbarrel \ pjellfsh \ pclam \ - pfishhk3 + pfishhk3 \ + prbridge hazard_src := hazard \ hfalling \ @@ -275,7 +276,8 @@ triggers_src := tcamlock \ tlook \ trestart \ tteleprt \ - twater + twater \ + tplatfrm utils_src := utils \ sincos \ diff --git a/source/platform/platdata.cpp b/source/platform/platdata.cpp index 0db57b17e..8eceb1e99 100644 --- a/source/platform/platdata.cpp +++ b/source/platform/platdata.cpp @@ -371,6 +371,18 @@ CNpcPlatform::NPC_PLATFORM_DATA CNpcPlatform::m_data[NPC_PLATFORM_TYPE_MAX] = NPC_PLATFORM_TIMER_NONE, }, + { // NPC_RISING_BRIDGE_PLATFORM + 3, + 128, + true, + DAMAGE__NONE, + 0, + 4, + NPC_PLATFORM_INFINITE_LIFE, + 0, + NPC_PLATFORM_TIMER_NONE, + }, + { // NPC_PLAYER_BUBBLE_PLATFORM 3, 128, @@ -425,6 +437,7 @@ CNpcPlatform::NPC_PLATFORM_UNIT_TYPE CNpcPlatform::mapEditConvertTable[NPC_PLATF NPC_STEERABLE_BARREL_PLATFORM, NPC_JELLYFISH_PLATFORM, NPC_FISH_HOOK_3_PLATFORM, + NPC_RISING_BRIDGE_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, NPC_CLAM_PLATFORM, }; diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 193cfda15..bbb060dc0 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -147,6 +147,10 @@ #include "platform\pfishhk3.h" #endif +#ifndef __PLATFORM_PRBRIDGE_H__ +#include "platform\prbridge.h" +#endif + #include "fx\fx.h" #include "fx\fxjfish.h" @@ -344,6 +348,12 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) break; } + case NPC_RISING_BRIDGE_PLATFORM: + { + platform = new ("rising bridge platform") CNpcRisingBridgePlatform; + break; + } + default: { ASSERT( 0 ); diff --git a/source/platform/platform.h b/source/platform/platform.h index 0c166584e..e05c2cbd9 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -81,6 +81,7 @@ public: NPC_STEERABLE_BARREL_PLATFORM, NPC_JELLYFISH_PLATFORM, NPC_FISH_HOOK_3_PLATFORM, + NPC_RISING_BRIDGE_PLATFORM, NPC_PLAYER_BUBBLE_PLATFORM, NPC_CLAM_PLATFORM, NPC_PLATFORM_TYPE_MAX, @@ -105,6 +106,7 @@ public: void setGraphic( sThingPlatform *ThisPlatform ); void setGraphic( u8 graphicNum ); virtual void setWaypoints( sThingPlatform *ThisPlatform ); + virtual void trigger() {;} static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static CNpcPlatform *Create(sThingPlatform *ThisPlatform); diff --git a/source/platform/prbridge.cpp b/source/platform/prbridge.cpp new file mode 100644 index 000000000..829e4a540 --- /dev/null +++ b/source/platform/prbridge.cpp @@ -0,0 +1,120 @@ +/*========================================================================= + + prbridge.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PRBRIDGE_H__ +#include "platform\prbridge.h" +#endif + +#ifndef __TRIGGERS_TPLATFRM_H__ +#include "triggers\tplatfrm.h" +#endif + +#ifndef __UTILS_HEADER__ +#include "utils\utils.h" +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRisingBridgePlatform::postInit() +{ + CNpcPlatform::postInit(); + + m_triggered = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRisingBridgePlatform::trigger() +{ + m_triggered = true; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRisingBridgePlatform::setWaypoints( sThingPlatform *ThisPlatform ) +{ + ASSERT( ThisPlatform->PointCount == 3 ); + + u16 *PntList=(u16*)MakePtr(ThisPlatform,sizeof(sThingPlatform)); + + u16 newXPos, newYPos; + + // get master platform init pos + + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + DVECTOR startPos; + startPos.vx = newXPos << 4; + startPos.vy = newYPos << 4; + + init( startPos ); + + m_extension = 0; + + // get master platform max vertical extension + + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + m_maxExtension = abs( ( newYPos << 4 ) - startPos.vy ) << 8; + + // get slave trigger position + + newXPos = (u16) *PntList; + PntList++; + newYPos = (u16) *PntList; + PntList++; + + CPlatformTrigger *trigger = NULL; // I hate having to do this just to keep the compiler quiet :/ (pkg) + + trigger = new ("PlatformTrigger") CPlatformTrigger(); + + ASSERT( trigger ); + + trigger->init(); + trigger->setPositionAndSize( newXPos << 4, newYPos << 4, 100, 0 ); + //trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4); + trigger->setPlatform( this ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcRisingBridgePlatform::processMovement( int _frames ) +{ + if ( m_triggered ) + { + m_triggered = false; + m_extension += ( m_data[m_type].speed * _frames ) << 8; + if ( m_extension > m_maxExtension ) + { + m_extension = m_maxExtension; + } + } + else + { + m_extension -= 64 * _frames; + + if ( m_extension < 0 ) + { + m_extension = 0; + } + } + + Pos.vy = m_base.vy - ( m_extension >> 8 ); +} diff --git a/source/platform/prbridge.h b/source/platform/prbridge.h new file mode 100644 index 000000000..980e6df2d --- /dev/null +++ b/source/platform/prbridge.h @@ -0,0 +1,34 @@ +/*========================================================================= + + prbridge.h + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PRBRIDGE_H__ +#define __PLATFORM_PRBRIDGE_H__ + +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + +class CNpcRisingBridgePlatform : public CNpcPlatform +{ +public: + virtual void postInit(); + virtual void trigger(); +protected: + virtual void setWaypoints( sThingPlatform *ThisPlatform ); + virtual void processMovement( int _frames ); + + s32 m_maxExtension; + u8 m_triggered; +}; + +#endif \ No newline at end of file diff --git a/source/triggers/tplatfrm.cpp b/source/triggers/tplatfrm.cpp new file mode 100644 index 000000000..0c95099d6 --- /dev/null +++ b/source/triggers/tplatfrm.cpp @@ -0,0 +1,110 @@ +/*========================================================================= + + tplatfrm.cpp + + Author: PKG + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#include "triggers\tplatfrm.h" + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + + +/* Std Lib + ------- */ + +/* Data + ---- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +/*---------------------------------------------------------------------- + Function Prototypes + ------------------- */ + +/*---------------------------------------------------------------------- + Vars + ---- */ + + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +#if defined (__USER_art__) || defined (__USER_sbart__) +#include "gfx\prim.h" +void CPlatformTrigger::render() +{ + DVECTOR ofs; + CRECT area; + + CTriggerThing::render(); + + ofs=CLevel::getCameraPos(); + area=getCollisionArea(); + area.x1-=ofs.vx; + area.y1-=ofs.vy; + area.x2-=ofs.vx; + area.y2-=ofs.vy; + + if(area.x1<=511&&area.x2>=0&& + area.y1<=255&&area.y2>=0) + { + POLY_F4 *f4; + f4=GetPrimF4(); + setXY4(f4,area.x1,area.y1, + area.x2,area.y1, + area.x1,area.y2, + area.x2,area.y2); + setRGB0(f4,0,255,0); + setSemiTrans(f4,true); + AddPrimToList(f4,0); + DrawLine(area.x1,area.y1,area.x2,area.y1,0,255,0,0); + DrawLine(area.x2,area.y1,area.x2,area.y2,0,255,0,0); + DrawLine(area.x2,area.y2,area.x1,area.y2,0,255,0,0); + DrawLine(area.x1,area.y2,area.x1,area.y1,0,255,0,0); + } +} +#endif + +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CPlatformTrigger::collidedWith(CThing *_thisThing) +{ + ASSERT(_thisThing->getThingType()==TYPE_PLAYER); + + CPlayer *player = (CPlayer *) _thisThing; + ATTACK_STATE playerState = player->getAttackState(); + + if ( playerState == ATTACK_STATE__BUTT_BOUNCE ) + { + m_platform->trigger(); + } +} + +/*=========================================================================== +end */ diff --git a/source/triggers/tplatfrm.h b/source/triggers/tplatfrm.h new file mode 100644 index 000000000..c933b945b --- /dev/null +++ b/source/triggers/tplatfrm.h @@ -0,0 +1,68 @@ +/*========================================================================= + + tplatfrm.h + + Author: Charles Blair + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __TRIGGERS_TPLATFRM_H__ +#define __TRIGGERS_TPLATFRM_H__ + +/*---------------------------------------------------------------------- + Includes + -------- */ + +#ifndef __THING_THING_H__ +#include "thing/thing.h" +#endif + +#ifndef __PLATFORM_PLATFORM_H__ +#include "platform\platform.h" +#endif + + +/* Std Lib + ------- */ + +/*---------------------------------------------------------------------- + Tyepdefs && Defines + ------------------- */ + +/*---------------------------------------------------------------------- + Structure defintions + -------------------- */ + +class CPlatformTrigger : public CTriggerThing +{ +public: +#if defined (__USER_art__) || defined (__USER_sbart__) + virtual void render(); +#endif + virtual void setPlatform( CNpcPlatform *platform ) {m_platform = platform;} + +protected: + virtual void collidedWith(CThing *_thisThing); + + CNpcPlatform *m_platform; +}; + +/*---------------------------------------------------------------------- + Globals + ------- */ + +/*---------------------------------------------------------------------- + Functions + --------- */ + +/*---------------------------------------------------------------------- */ + +#endif /* __TRIGGERS_TPLATFRM_H__ */ + +/*=========================================================================== + end */ diff --git a/tools/Data/bin/MkLevel.ini b/tools/Data/bin/MkLevel.ini index bca642512..ac98d774b 100644 --- a/tools/Data/bin/MkLevel.ini +++ b/tools/Data/bin/MkLevel.ini @@ -110,6 +110,7 @@ SteerableBarrelPlatform=24 RockGeyser=7 Retracting=6 RollingOildrumPlatform=24 +RisingBridge=27 ################################################ # Triggers diff --git a/tools/MapEdit/platform.ini b/tools/MapEdit/platform.ini index 7dc15d5ac..2dbb016c3 100644 --- a/tools/MapEdit/platform.ini +++ b/tools/MapEdit/platform.ini @@ -105,3 +105,6 @@ Gfx=..\..\Graphics\platforms\Wooden\Wooden.gin [RollingOildrumPlatform] Gfx=..\..\Graphics\platforms\rolling_oildrum\roll_oil.gin + +[RisingBridge] +Gfx=..\..\Graphics\platforms\seesaw\seesaw_wooden.gin diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index d14d17343..cbe83d4ad 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1397,6 +1397,14 @@ SOURCE=..\..\..\source\platform\praft.h # End Source File # Begin Source File +SOURCE=..\..\..\source\platform\prbridge.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\platform\prbridge.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\platform\pretract.cpp # End Source File # Begin Source File @@ -1841,6 +1849,14 @@ SOURCE=..\..\..\source\triggers\tlook.h # End Source File # Begin Source File +SOURCE=..\..\..\source\triggers\tplatfrm.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\triggers\tplatfrm.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\triggers\trestart.cpp # End Source File # Begin Source File