This commit is contained in:
parent
08e187289a
commit
28ed71d254
4 changed files with 69 additions and 15 deletions
|
@ -22,6 +22,10 @@
|
|||
#include "sound\sound.h"
|
||||
#endif
|
||||
|
||||
#ifndef __PLAYER_PLAYER_H__
|
||||
#include "player\player.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* Std Lib
|
||||
------- */
|
||||
|
@ -58,9 +62,30 @@ void CSecretAreaTrigger::collidedWith(CThing *_thisThing)
|
|||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
CSoundMediator::playSfx(CSoundMediator::SFX_SECRET_AREA);
|
||||
shutdown();
|
||||
delete this;
|
||||
// SB *might* be chopping to hit this trigger, so we only do the collision
|
||||
// if he would normally hit it.
|
||||
int x,y,w,h;
|
||||
DVECTOR pos;
|
||||
CRECT thisRect;
|
||||
CRECT const &thatRect=getCollisionArea();
|
||||
int collided=true;
|
||||
|
||||
((CPlayer*)_thisThing)->getPlayerNormalCollisionSize(&x,&y,&w,&h);
|
||||
pos=_thisThing->getPos();
|
||||
thisRect.x1=pos.vx+x-(w/2);
|
||||
thisRect.y1=pos.vy+y-(h/2);
|
||||
thisRect.x2=thisRect.x1+w;
|
||||
thisRect.y2=thisRect.y1+h;
|
||||
|
||||
if (thisRect.x2<thatRect.x1 || thisRect.x1>thatRect.x2) collided=false;
|
||||
if (thisRect.y2<thatRect.y1 || thisRect.y1>thatRect.y2) collided=false;
|
||||
if(collided)
|
||||
{
|
||||
// Ok.. so we've actually hit the thing properly :)
|
||||
CSoundMediator::playSfx(CSoundMediator::SFX_SECRET_AREA);
|
||||
shutdown();
|
||||
delete this;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,21 +73,42 @@ void CTeleportTrigger::collidedWith(CThing *_thisThing)
|
|||
{
|
||||
case TYPE_PLAYER:
|
||||
{
|
||||
if ( chapter == 5 && level == 5 )
|
||||
// SB *might* be chopping to hit this trigger, so we only do the collision
|
||||
// if he would normally hit it.
|
||||
int x,y,w,h;
|
||||
DVECTOR pos;
|
||||
CRECT thisRect;
|
||||
CRECT const &thatRect=getCollisionArea();
|
||||
int collided=true;
|
||||
|
||||
((CPlayer*)_thisThing)->getPlayerNormalCollisionSize(&x,&y,&w,&h);
|
||||
pos=_thisThing->getPos();
|
||||
thisRect.x1=pos.vx+x-(w/2);
|
||||
thisRect.y1=pos.vy+y-(h/2);
|
||||
thisRect.x2=thisRect.x1+w;
|
||||
thisRect.y2=thisRect.y1+h;
|
||||
|
||||
if (thisRect.x2<thatRect.x1 || thisRect.x1>thatRect.x2) collided=false;
|
||||
if (thisRect.y2<thatRect.y1 || thisRect.y1>thatRect.y2) collided=false;
|
||||
if(collided)
|
||||
{
|
||||
if ( !CNpcGaryFriend::hasReachedDoor() )
|
||||
// Ok.. so we've actually hit the thing properly :)
|
||||
if ( chapter == 5 && level == 5 )
|
||||
{
|
||||
// if we're on chapter 1, level 5, check Gary has reached the teleport point
|
||||
// if he hasn't, don't let Spongey through
|
||||
if ( !CNpcGaryFriend::hasReachedDoor() )
|
||||
{
|
||||
// if we're on chapter 1, level 5, check Gary has reached the teleport point
|
||||
// if he hasn't, don't let Spongey through
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(GameScene.triggerTeleportEffect())
|
||||
{
|
||||
((CPlayer*)_thisThing)->clearPlatform();
|
||||
((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
|
||||
if(GameScene.triggerTeleportEffect())
|
||||
{
|
||||
((CPlayer*)_thisThing)->clearPlatform();
|
||||
((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue