SBSPSS/source/platform/pbubble.cpp

127 lines
3.1 KiB
C++
Raw Normal View History

2001-04-23 18:54:49 +02:00
/*=========================================================================
pbubble.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __PLATFORM_PBUBBLE_H__
#include "platform\pbubble.h"
#endif
2001-06-04 23:16:15 +02:00
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __SPR_SPRITES_H__
#include <sprites.h>
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBubblePlatform::postInit()
{
2001-07-03 20:32:04 +02:00
setCollisionSize( 30, 30 );
setCollisionCentreOffset( 0, -15 );
calculateNonRotatedCollisionData();
setCollisionAngle( m_tiltAngle >> 8 );
2001-06-04 23:16:15 +02:00
m_pop = false;
2001-07-03 20:32:04 +02:00
m_scale = ONE;
}
2001-06-19 22:07:57 +02:00
2001-07-03 20:32:04 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-06-19 22:07:57 +02:00
2001-07-03 20:32:04 +02:00
void CNpcBubblePlatform::shutdown()
{
if ( m_soundId != NOT_PLAYING )
{
CSoundMediator::stopAndUnlockSfx( (xmPlayingId) m_soundId );
}
2001-06-19 22:07:57 +02:00
2001-07-03 20:32:04 +02:00
CPlatformThing::shutdown();
2001-06-04 23:16:15 +02:00
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcBubblePlatform::render()
{
2001-07-03 20:32:04 +02:00
SprFrame=0;
2001-06-04 23:16:15 +02:00
if ( m_isActive || m_pop )
{
CPlatformThing::render();
// Render
if (canRender())
{
DVECTOR &renderPos=getRenderPos();
if ( m_pop )
{
2001-08-21 17:08:11 +02:00
SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BALLOONBURST, renderPos.vx, renderPos.vy - 16, 4096 << 1, 4096 << 1, 0, 12 );
2001-06-04 23:16:15 +02:00
setRGB0( SprFrame, 128, 128, 255 );
}
else
{
2001-06-28 21:43:45 +02:00
// Evil hard coded Offsets
2001-08-21 17:08:11 +02:00
POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM__BUBBLE_1, renderPos.vx, renderPos.vy - 16, m_scale, ONE, 0, 12 );
2001-06-28 21:43:45 +02:00
setRGB0( SprFrame, 128, 128, 255 );
2001-08-08 00:40:27 +02:00
SprFrame->u1++; SprFrame->u3++;
SprFrame->v2++; SprFrame->v3++;
2001-06-04 23:16:15 +02:00
}
}
}
}
2001-04-23 18:54:49 +02:00
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2001-07-03 20:32:04 +02:00
int CNpcBubblePlatform::checkCollisionAgainst(CThing *_thisThing, int _frames)
2001-04-23 18:54:49 +02:00
{
2001-07-03 20:32:04 +02:00
switch(_thisThing->getThingType())
2001-05-05 01:12:26 +02:00
{
2001-07-03 20:32:04 +02:00
case TYPE_PLAYERPROJECTILE:
return( false );
2001-05-22 22:39:46 +02:00
2001-07-03 20:32:04 +02:00
default:
2001-05-22 22:39:46 +02:00
{
2001-07-03 20:32:04 +02:00
int collided = false;
2001-05-22 22:39:46 +02:00
2001-07-03 20:32:04 +02:00
if ( m_detectCollision && m_isActive && !isSetToShutdown() && !m_pop )
2001-05-22 22:39:46 +02:00
{
2001-07-03 20:32:04 +02:00
CRECT thisRect, thatRect;
2001-06-19 22:21:26 +02:00
2001-07-03 20:32:04 +02:00
thisRect = getCollisionArea();
thatRect = _thisThing->getCollisionArea();
2001-06-19 22:21:26 +02:00
2001-07-23 21:26:37 +02:00
DVECTOR const &thisPosDelta = getPosDelta();
int ThisAbsY=abs(thisPosDelta.vy)>>1;
thisRect.y1 -= ThisAbsY;
thisRect.y2 += ThisAbsY;
DVECTOR const &ThatPosDelta = _thisThing->getPosDelta();
int ThatAbsY=abs(ThatPosDelta.vy)>>1;
thatRect.y1 -= ThatAbsY;
thatRect.y2 += ThatAbsY;
2001-07-03 20:32:04 +02:00
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 );
2001-06-04 23:16:15 +02:00
}
}
}
2001-07-03 20:32:04 +02:00