From 9a0ce0adc6cfac10b0c6e17e4af3ef0711f71582 Mon Sep 17 00:00:00 2001 From: Charles Date: Tue, 3 Jul 2001 18:32:04 +0000 Subject: [PATCH] --- makefile.gaz | 3 +- source/platform/pbgeyser.cpp | 4 - source/platform/pbubble.cpp | 99 +++++++++---------- source/platform/pbubble.h | 8 +- source/platform/pcbubble.cpp | 74 +------------- source/platform/pcbubble.h | 12 +-- source/platform/platform.cpp | 6 +- source/platform/platform.h | 4 +- source/platform/pplayer.cpp | 79 +-------------- source/platform/pplayer.h | 13 +-- .../spongebob project/spongebob project.dsp | 8 ++ 11 files changed, 81 insertions(+), 229 deletions(-) diff --git a/makefile.gaz b/makefile.gaz index 70f5b1370..f89e0584a 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -137,7 +137,8 @@ platform_src := platform \ plift \ plurve \ psoil \ - pbubtube + pbubtube \ + pgbubble hazard_src := hazard \ hfalling \ diff --git a/source/platform/pbgeyser.cpp b/source/platform/pbgeyser.cpp index e098a372e..bc55406aa 100644 --- a/source/platform/pbgeyser.cpp +++ b/source/platform/pbgeyser.cpp @@ -23,10 +23,6 @@ #include "game\game.h" #endif -#ifndef __PLATFORM_PBUBBLE_H__ -#include "platform\pbubble.h" -#endif - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcGeyserPlatformGenerator::collidedWith(CThing *_thisThing) diff --git a/source/platform/pbubble.cpp b/source/platform/pbubble.cpp index ba71fad21..4208e564c 100644 --- a/source/platform/pbubble.cpp +++ b/source/platform/pbubble.cpp @@ -28,25 +28,33 @@ void CNpcBubblePlatform::postInit() { - CNpcPlatform::postInit(); + setCollisionSize( 30, 30 ); + setCollisionCentreOffset( 0, -15 ); + + calculateNonRotatedCollisionData(); + setCollisionAngle( m_tiltAngle >> 8 ); m_pop = false; + m_scale = ONE; +} - s32 minX, maxX, minY, maxY; +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - m_npcPath.getPathXExtents( &minX, &maxX ); - m_npcPath.getPathYExtents( &minY, &maxY ); +void CNpcBubblePlatform::shutdown() +{ + if ( m_soundId != NOT_PLAYING ) + { + CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId ); + } - m_thinkArea.x1 = minX; - m_thinkArea.x2 = maxX; - m_thinkArea.y1 = minY; - m_thinkArea.y2 = maxY; + CPlatformThing::shutdown(); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcBubblePlatform::render() { + SprFrame=0; if ( m_isActive || m_pop ) { CPlatformThing::render(); @@ -58,15 +66,14 @@ void CNpcBubblePlatform::render() if ( m_pop ) { - POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 10 ); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 10 ); setRGB0( SprFrame, 128, 128, 255 ); } else { // Evil hard coded Offsets - POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printFT4( FRM__BUBBLE_1, renderPos.vx-16, renderPos.vy-32, 0, 0, 10 ); + POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BUBBLE_1, renderPos.vx, renderPos.vy - 16, m_scale, ONE, 0, 10 ); setRGB0( SprFrame, 128, 128, 255 ); -// m_modelGfx->Render(renderPos); } } } @@ -74,57 +81,43 @@ void CNpcBubblePlatform::render() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcBubblePlatform::processMovement( int _frames ) +int CNpcBubblePlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) { - if ( !isSetToShutdown() && !m_pop ) + switch(_thisThing->getThingType()) { - Pos.vy -= m_speed * _frames; + case TYPE_PLAYERPROJECTILE: + return( false ); - if ( m_npcPath.getWaypointCount() ) + default: { - s32 minY, maxY; + int collided = false; - m_npcPath.getPathYExtents( &minY, &maxY ); - - if ( Pos.vy < minY ) + if ( m_detectCollision && m_isActive && !isSetToShutdown() && !m_pop ) { - m_lifetime = GameState::getOneSecondInFrames() >> 2; - m_pop = true; + 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; + } } - } - else - { - if ( Pos.vy < 0 ) - { - m_lifetime = GameState::getOneSecondInFrames() >> 2; - m_pop = true; - } - } - DVECTOR offset = CLevel::getCameraPos(); - - s32 yPos = Pos.vy - offset.vy; - - if ( yPos < 0 ) - { - setToShutdown(); + return( collided ); } } } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcBubblePlatform::processLifetime( int _frames ) -{ - if ( m_pop ) - { - if ( m_lifetime <= 0 ) - { - setToShutdown(); - } - else - { - m_lifetime = 0; - } - } -} diff --git a/source/platform/pbubble.h b/source/platform/pbubble.h index 01bbfd357..bf0898d3e 100644 --- a/source/platform/pbubble.h +++ b/source/platform/pbubble.h @@ -23,11 +23,15 @@ class CNpcBubblePlatform : public CNpcPlatform public: virtual void render(); virtual void postInit(); + virtual void shutdown(); + virtual void setGraphic( sThingPlatform *ThisPlatform ) {} + virtual void setGraphic( u8 graphicNum ) {} protected: - virtual void processLifetime( int _frames ); - virtual void processMovement( int _frames ); + virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); u8 m_pop; + s16 m_scale; + POLY_FT4 *SprFrame; }; #endif \ No newline at end of file diff --git a/source/platform/pcbubble.cpp b/source/platform/pcbubble.cpp index e0d544935..436ae3612 100644 --- a/source/platform/pcbubble.cpp +++ b/source/platform/pcbubble.cpp @@ -28,41 +28,11 @@ void CNpcCollapsingBubblePlatform::postInit() { - CNpcPlatform::postInit(); + CNpcBubblePlatform::postInit(); - m_pop = false; - m_scale = ONE; m_startCollapse = false; } -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcCollapsingBubblePlatform::render() -{ - SprFrame=0; - if ( m_isActive || m_pop ) - { - CPlatformThing::render(); - - // Render - if (canRender()) - { - DVECTOR &renderPos=getRenderPos(); - - if ( m_pop ) - { - SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 10 ); - setRGB0( SprFrame, 128, 128, 255 ); - } - else - { - // Evil hard coded Offsets - POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BUBBLE_1, renderPos.vx, renderPos.vy - 16, m_scale, ONE, 0, 10 ); - setRGB0( SprFrame, 128, 128, 255 ); - } - } - } -} - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcCollapsingBubblePlatform::processLifetime( int _frames ) @@ -141,48 +111,6 @@ void CNpcCollapsingBubblePlatform::processLifetime( int _frames ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -int CNpcCollapsingBubblePlatform::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 ); - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CNpcCollapsingAcridPlatform::render() { diff --git a/source/platform/pcbubble.h b/source/platform/pcbubble.h index 2038d6f55..0d2d92ca4 100644 --- a/source/platform/pcbubble.h +++ b/source/platform/pcbubble.h @@ -14,22 +14,18 @@ #ifndef __PLATFORM_PCBUBBLE_H__ #define __PLATFORM_PCBUBBLE_H__ -#ifndef __PLATFORM_PLATFORM_H__ -#include "platform\platform.h" +#ifndef __PLATFORM_PBUBBLE_H__ +#include "platform\pbubble.h" #endif -class CNpcCollapsingBubblePlatform : public CNpcPlatform +class CNpcCollapsingBubblePlatform : public CNpcBubblePlatform { public: - virtual void render(); virtual void postInit(); + virtual CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} protected: virtual void processLifetime( int _frames ); - virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); - u8 m_pop; u8 m_startCollapse; - s16 m_scale; - POLY_FT4 *SprFrame; }; class CNpcCollapsingAcridPlatform : public CNpcCollapsingBubblePlatform diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 7237cdf05..e2aed5942 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -203,6 +203,10 @@ #include "platform\pplayer.h" #endif +#ifndef __PLATFORM_PGBUBBLE_H__ +#include "platform\pgbubble.h" +#endif + #include "fx\fx.h" #include "fx\fxjfish.h" @@ -231,7 +235,7 @@ CNpcPlatform *CNpcPlatform::Create(int Type) case NPC_BUBBLE_PLATFORM: { - platform = new ("bubble platform") CNpcBubblePlatform; + platform = new ("geyser bubble platform") CNpcGeyserBubblePlatform; break; } diff --git a/source/platform/platform.h b/source/platform/platform.h index 90509532a..b2de671a1 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -117,8 +117,8 @@ public: void setTiltable( bool isTiltable ); void setWaypointPtr( u16 *newPtr ) {m_npcPath.setWaypointPtr( newPtr );} void setWaypointCount( u8 newCount ) {m_npcPath.setWaypointCount( newCount );} - void setGraphic( sThingPlatform *ThisPlatform ); - void setGraphic( u8 graphicNum ); + virtual void setGraphic( sThingPlatform *ThisPlatform ); + virtual void setGraphic( u8 graphicNum ); virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void trigger() {;} virtual u8 isCart() {return( false );} diff --git a/source/platform/pplayer.cpp b/source/platform/pplayer.cpp index c0243d61c..1a5c82e3a 100644 --- a/source/platform/pplayer.cpp +++ b/source/platform/pplayer.cpp @@ -26,18 +26,15 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcPlayerBubblePlatform::postInit() +/*void CNpcPlayerBubblePlatform::postInit() { - CNpcPlatform::postInit(); - - m_pop = false; - m_scale = ONE; + CNpcBubblePlatform::postInit(); setCollisionSize( 30, 30 ); setCollisionCentreOffset( 0, -15 ); calculateNonRotatedCollisionData(); -} +}*/ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -66,73 +63,3 @@ void CNpcPlayerBubblePlatform::processLifetime( int _frames ) } } } - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void CNpcPlayerBubblePlatform::render() -{ - if ( m_isActive ) - { - CPlatformThing::render(); - - // Render - if (canRender()) - { - DVECTOR &renderPos=getRenderPos(); - - if ( m_pop ) - { - POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 10 ); - setRGB0( SprFrame, 128, 128, 255 ); - } - else - { - // Evil hard coded Offsets - POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BUBBLE_1, renderPos.vx, renderPos.vy - 16, m_scale, ONE, 0, 10 ); - setRGB0( SprFrame, 128, 128, 255 ); - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -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 ddb9f412e..9dee2f3de 100644 --- a/source/platform/pplayer.h +++ b/source/platform/pplayer.h @@ -14,22 +14,17 @@ #ifndef __PLATFORM_PPLAYER_H__ #define __PLATFORM_PPLAYER_H__ -#ifndef __PLATFORM_PLATFORM_H__ -#include "platform\platform.h" +#ifndef __PLATFORM_PBUBBLE_H__ +#include "platform\pbubble.h" #endif -class CNpcPlayerBubblePlatform : public CNpcPlatform +class CNpcPlayerBubblePlatform : public CNpcBubblePlatform { public: - virtual void postInit(); - virtual void render(); - virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); + //virtual void postInit(); virtual CRECT const *getThinkBBox() {return( CThing::getThinkBBox() );} protected: virtual void processLifetime( int _frames ); - - u8 m_pop; - s16 m_scale; }; #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 d6a16117d..658c3c462 100644 --- a/users/paul/spongebob project/spongebob project.dsp +++ b/users/paul/spongebob project/spongebob project.dsp @@ -1617,6 +1617,14 @@ SOURCE=..\..\..\source\platform\pfishhk3.h # End Source File # Begin Source File +SOURCE=..\..\..\source\platform\pgbubble.cpp +# End Source File +# Begin Source File + +SOURCE=..\..\..\source\platform\pgbubble.h +# End Source File +# Begin Source File + SOURCE=..\..\..\source\platform\pgeyser.cpp # End Source File # Begin Source File