From aab11cab87e255b25c5b976e063f754b5a9854cb Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 29 May 2001 16:55:15 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/platform/pplayer.cpp | 125 ++++++++++++++++++ source/platform/pplayer.h | 8 ++ .../spongebob project/spongebob project.dsp | 4 + 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 source/platform/pplayer.cpp diff --git a/makefile.gaz b/makefile.gaz index 3ed7a5bc9..ffc7ed6f4 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -127,7 +127,8 @@ platform_src := platform \ prbridge \ pbaloon \ ptrpdoor \ - pconveyr + pconveyr \ + pplayer hazard_src := hazard \ hfalling \ diff --git a/source/platform/pplayer.cpp b/source/platform/pplayer.cpp new file mode 100644 index 000000000..118f60fd4 --- /dev/null +++ b/source/platform/pplayer.cpp @@ -0,0 +1,125 @@ +/*========================================================================= + + pplayer.cpp + + Author: CRB + Created: + Project: Spongebob + Purpose: + + Copyright (c) 2001 Climax Development Ltd + +===========================================================================*/ + +#ifndef __PLATFORM_PPLAYER_H__ +#include "platform\pplayer.h" +#endif + +#ifndef __GAME_GAME_H__ +#include "game\game.h" +#endif + +#ifndef __SPR_SPRITES_H__ +#include +#endif + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPlayerBubblePlatform::postInit() +{ + CNpcPlatform::postInit(); + + m_pop = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPlayerBubblePlatform::processLifetime( int _frames ) +{ + m_lifetime -= _frames; + + if ( m_pop ) + { + if ( m_lifetime <= 0 ) + { + setToShutdown(); + } + } + else + { + if ( m_lifetime <= 0 ) + { + m_pop = true; + + m_lifetime = GameState::getOneSecondInFrames() >> 1; + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcPlayerBubblePlatform::render() +{ + if ( m_isActive ) + { + CPlatformThing::render(); + + // Render + if (canRender()) + { + DVECTOR &renderPos=getRenderPos(); + + if ( m_pop ) + { + CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 10 ); + } + else + { + m_modelGfx->Render(renderPos); + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +int CNpcPlayerBubblePlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) +{ + switch(_thisThing->getThingType()) + { + case TYPE_PLAYERPROJECTILE: + return( false ); + + default: + { + int collided = false; + + if ( m_detectCollision && m_isActive && !isSetToShutdown() && !m_pop ) + { + CRECT thisRect, thatRect; + + thisRect = getCollisionArea(); + thatRect = _thisThing->getCollisionArea(); + + DVECTOR posDelta = getPosDelta(); + + thisRect.y1 -= abs( posDelta.vy ) >> 1; + thisRect.y2 += abs( posDelta.vy ) >> 1; + + posDelta = _thisThing->getPosDelta(); + + thatRect.y1 -= abs( posDelta.vy ) >> 1; + thatRect.y2 += abs( posDelta.vy ) >> 1; + + if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& + ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) + { + collided = true; + } + } + + return( collided ); + } + } +} diff --git a/source/platform/pplayer.h b/source/platform/pplayer.h index 6845c7bc3..b0838d1ea 100644 --- a/source/platform/pplayer.h +++ b/source/platform/pplayer.h @@ -20,6 +20,14 @@ class CNpcPlayerBubblePlatform : public CNpcPlatform { +public: + virtual void postInit(); + virtual void render(); + virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); +protected: + virtual void processLifetime( int _frames ); + + u8 m_pop; }; #endif \ No newline at end of file diff --git a/users/paul/spongebob project/spongebob project.dsp b/users/paul/spongebob project/spongebob project.dsp index abc785019..281e2c4d8 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1437,6 +1437,10 @@ SOURCE=..\..\..\source\platform\ppendulm.h # End Source File # Begin Source File +SOURCE=..\..\..\source\platform\pplayer.cpp +# End Source File +# Begin Source File + SOURCE=..\..\..\source\platform\pplayer.h # End Source File # Begin Source File