This commit is contained in:
Charles 2001-06-04 12:54:44 +00:00
parent 30272803d0
commit 25de06c1a6
21 changed files with 595 additions and 41 deletions

View File

@ -297,7 +297,9 @@ triggers_src := trigger \
tplatfrm \
tgarygo \
tfemit \
tifemit
tifemit \
tggleft \
tgstop
utils_src := utils \
sincos \

View File

@ -169,3 +169,13 @@ void CNpcGaryFriend::render()
setCollisionCentreOffset( ( boundingBox.XMax + boundingBox.XMin ) >> 1, ( boundingBox.YMax + boundingBox.YMin ) >> 1 );
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CNpcGaryFriend::startLeft()
{
start();
m_extension = EXTEND_LEFT;
m_reversed = true;
}

View File

@ -26,6 +26,8 @@ public:
virtual void setupWaypoints( sThingActor *ThisActor );
DVECTOR const &getTriggerPos() {return( m_triggerPos );}
void start() {m_started = true;}
void stop() {m_started = false;}
void startLeft();
virtual void render();
protected:

View File

@ -31,6 +31,10 @@
#include "game\game.h"
#endif
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -372,7 +376,50 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing )
}
case TYPE_NPC:
{
CNpcFriend *friendNpc;
DVECTOR friendPos;
CRECT collisionArea;
friendNpc = (CNpcFriend*) _thisThing;
friendPos = friendNpc->getPos();
collisionArea=getCollisionArea();
s32 threshold = abs( collisionArea.y2 - collisionArea.y1 );
if ( threshold > 16 )
{
threshold = 16;
}
if( friendPos.vx >= collisionArea.x1 && friendPos.vx <= collisionArea.x2 )
{
if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) )
{
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
friendNpc->setPlatform( this );
m_contact = true;
}
else
{
if( friendPos.vy >= collisionArea.y1 && friendPos.vy <= collisionArea.y2 )
{
int height = getHeightFromPlatformAtPosition( friendPos.vx, friendPos.vy );
if ( height >= -threshold && height < 1 )
{
friendNpc->setPlatform( this );
m_contact = true;
}
}
}
}
break;
}
case TYPE_HAZARD:
{

View File

@ -543,11 +543,27 @@ DVECTOR const &CamPos=CLevel::getCameraPos();
thing1=thing1->m_nextCollisionThing;
}
// Enemy -> Player projectile collision
thing1=s_CollisionLists[CThing::TYPE_PLAYERPROJECTILE];
thing2=s_CollisionLists[CThing::TYPE_ENEMY];
// Friend -> Trigger collision
thing1=s_CollisionLists[CThing::TYPE_TRIGGER];
while(thing1)
{
thing2=s_CollisionLists[CThing::TYPE_NPC];
while(thing2)
{
if(thing1->checkCollisionAgainst(thing2, _frames))
{
thing1->collidedWith(thing2);
}
thing2=thing2->m_nextCollisionThing;
}
thing1=thing1->m_nextCollisionThing;
}
// Enemy -> Player projectile collision
thing1=s_CollisionLists[CThing::TYPE_PLAYERPROJECTILE];
while(thing1)
{
thing2=s_CollisionLists[CThing::TYPE_ENEMY];
while(thing2)
{
if(thing1->checkCollisionAgainst(thing2, _frames))

View File

@ -57,11 +57,20 @@ void CCameraLockTrigger::collidedWith(CThing *_thisThing)
{
CPlayer::CameraBox camBox={m_boxX1,m_boxY1,m_boxX2,m_boxY2};
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
((CPlayer*)_thisThing)->setCameraBox(camBox);
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
((CPlayer*)_thisThing)->setCameraBox(camBox);
PAUL_DBGMSG("HIT CAM BOX TRIGGER");
break;
}
default:
break;
}
}
/*===========================================================================

View File

@ -2,7 +2,7 @@
tgarygo.cpp
Author: PKG
Author: CRB
Created:
Project: Spongebob
Purpose:
@ -96,10 +96,18 @@ void CGaryStartTrigger::render()
---------------------------------------------------------------------- */
void CGaryStartTrigger::collidedWith(CThing *_thisThing)
{
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
m_gary->start();
CPlayer *player = (CPlayer *) _thisThing;
m_gary->start();
break;
}
default:
break;
}
}
/*===========================================================================

127
source/triggers/tggleft.cpp Normal file
View File

@ -0,0 +1,127 @@
/*=========================================================================
tggleft.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tggleft.h"
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __FRIEND_FGARY_H__
#include "friend\fgary.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 CGaryGoLeftTrigger::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 CGaryGoLeftTrigger::collidedWith(CThing *_thisThing)
{
switch( _thisThing->getThingType() )
{
case TYPE_NPC:
{
if ( _thisThing->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY )
{
CNpcGaryFriend *gary = (CNpcGaryFriend *) _thisThing;
gary->startLeft();
}
break;
}
default:
break;
}
}
/*===========================================================================
end */

60
source/triggers/tggleft.h Normal file
View File

@ -0,0 +1,60 @@
/*=========================================================================
tggleft.h
Author: Charles Blair
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __TRIGGERS_TGGLEFT_H__
#define __TRIGGERS_TGGLEFT_H__
/*----------------------------------------------------------------------
Includes
-------- */
#ifndef __THING_THING_H__
#include "thing/thing.h"
#endif
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class CGaryGoLeftTrigger : public CTrigger
{
public:
#if defined (__USER_art__) || defined (__USER_sbart__)
virtual void render();
#endif
protected:
virtual void collidedWith(CThing *_thisThing);
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __TRIGGERS_TPLATFRM_H__ */
/*===========================================================================
end */

127
source/triggers/tgstop.cpp Normal file
View File

@ -0,0 +1,127 @@
/*=========================================================================
tgstop.cpp
Author: CRB
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
/*----------------------------------------------------------------------
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tgstop.h"
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
#ifndef __FRIEND_FRIEND_H__
#include "friend\friend.h"
#endif
#ifndef __FRIEND_FGARY_H__
#include "friend\fgary.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 CGaryGoLeftTrigger::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 CGaryStopTrigger::collidedWith(CThing *_thisThing)
{
switch( _thisThing->getThingType() )
{
case TYPE_NPC:
{
if ( _thisThing->getThingSubType() == CNpcFriend::NPC_FRIEND_GARY )
{
CNpcGaryFriend *gary = (CNpcGaryFriend *) _thisThing;
gary->stop();
}
break;
}
default:
break;
}
}
/*===========================================================================
end */

60
source/triggers/tgstop.h Normal file
View File

@ -0,0 +1,60 @@
/*=========================================================================
tgstop.h
Author: Charles Blair
Created:
Project: Spongebob
Purpose:
Copyright (c) 2001 Climax Development Ltd
===========================================================================*/
#ifndef __TRIGGERS_TGSTOP_H__
#define __TRIGGERS_TGSTOP_H__
/*----------------------------------------------------------------------
Includes
-------- */
#ifndef __THING_THING_H__
#include "thing/thing.h"
#endif
/* Std Lib
------- */
/*----------------------------------------------------------------------
Tyepdefs && Defines
------------------- */
/*----------------------------------------------------------------------
Structure defintions
-------------------- */
class CGaryStopTrigger : public CTrigger
{
public:
#if defined (__USER_art__) || defined (__USER_sbart__)
virtual void render();
#endif
protected:
virtual void collidedWith(CThing *_thisThing);
};
/*----------------------------------------------------------------------
Globals
------- */
/*----------------------------------------------------------------------
Functions
--------- */
/*---------------------------------------------------------------------- */
#endif /* __TRIGGERS_TPLATFRM_H__ */
/*===========================================================================
end */

View File

@ -96,11 +96,19 @@ void CLevelExitTrigger::render()
---------------------------------------------------------------------- */
void CLevelExitTrigger::collidedWith(CThing *_thisThing)
{
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
#if !defined (__USER_art__) && !defined (__USER_sbart__)
CGameScene::levelFinished();
CGameScene::levelFinished();
#endif
break;
}
default:
break;
}
}
/*===========================================================================

View File

@ -56,17 +56,26 @@ void CLookTrigger::collidedWith(CThing *_thisThing)
DVECTOR collCentre;
CRECT collArea;
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
// Only collide if players feet are inside the trigger
collCentre=((CPlayer*)_thisThing)->getCollisionCentre();
collArea.x1=collCentre.vx-5;
collArea.y1=collCentre.vy-5;
collArea.x2=collArea.x1+10;
collArea.y2=collArea.y1+10;
if(checkCollisionAgainstArea(&collArea))
switch( _thisThing->getThingType() )
{
((CPlayer*)_thisThing)->setLedgeLookAhead(+4);
case TYPE_PLAYER:
{
// Only collide if players feet are inside the trigger
collCentre=((CPlayer*)_thisThing)->getCollisionCentre();
collArea.x1=collCentre.vx-5;
collArea.y1=collCentre.vy-5;
collArea.x2=collArea.x1+10;
collArea.y2=collArea.y1+10;
if(checkCollisionAgainstArea(&collArea))
{
((CPlayer*)_thisThing)->setLedgeLookAhead(+4);
}
break;
}
default:
break;
}
}

View File

@ -96,14 +96,23 @@ void CPlatformTrigger::render()
---------------------------------------------------------------------- */
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 )
switch( _thisThing->getThingType() )
{
m_platform->trigger();
case TYPE_PLAYER:
{
CPlayer *player = (CPlayer *) _thisThing;
ATTACK_STATE playerState = player->getAttackState();
if ( playerState == ATTACK_STATE__BUTT_BOUNCE )
{
m_platform->trigger();
}
break;
}
default:
break;
}
}

View File

@ -57,12 +57,21 @@ void CRestartPointTrigger::collidedWith(CThing *_thisThing)
CRECT collisionArea;
DVECTOR respawnPos;
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
collisionArea=getCollisionArea();
respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2);
respawnPos.vy=collisionArea.y2;
((CPlayer*)_thisThing)->setRespawnPos(respawnPos);
collisionArea=getCollisionArea();
respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2);
respawnPos.vy=collisionArea.y2;
((CPlayer*)_thisThing)->setRespawnPos(respawnPos);
break;
}
default:
break;
}
}
/*===========================================================================

View File

@ -51,6 +51,14 @@
#include "triggers\tifemit.h"
#endif
#ifndef __TRIGGERS_TGGLEFT_H__
#include "triggers\tggleft.h"
#endif
#ifndef __TRIGGERS_TGSTOP_H__
#include "triggers\tgstop.h"
#endif
#ifndef __GAME_GAME_H__
#include "game\game.h"
#endif
@ -95,7 +103,7 @@ CTrigger *trigger;
// Gary start trigger
case TRIGGER_GARYSTART:
trigger=(CGaryStartTrigger*)new( "GaryStartTrigger") CGaryStartTrigger();
trigger=(CGaryStartTrigger*)new("GaryStartTrigger") CGaryStartTrigger();
break;
// Flame emitter
@ -103,6 +111,16 @@ CTrigger *trigger;
trigger=(CFlameEmitterTrigger*)new( "FlameEmitterTrigger") CFlameEmitterTrigger();
break;
// Gary stop trigger
case TRIGGER_GARYSTOP:
trigger=(CGaryStopTrigger*)new("GaryStopTrigger") CGaryStopTrigger();
break;
// Gary go left trigger
case TRIGGER_GARYGOLEFT:
trigger=(CGaryGoLeftTrigger*)new("GaryGoLeftTrigger") CGaryGoLeftTrigger();
break;
case TRIGGER_INTERMITTENTFLAMEEMITTER:
trigger=(CIntermittentFlameEmitterTrigger*)new( "IntermittentFlameEmitterTrigger") CIntermittentFlameEmitterTrigger();
break;

View File

@ -32,6 +32,8 @@ enum TRIGGER_TYPE
TRIGGER_GARYSTART,
TRIGGER_FLAMEEMITTER,
TRIGGER_INTERMITTENTFLAMEEMITTER,
TRIGGER_GARYSTOP,
TRIGGER_GARYGOLEFT,
// Code based triggers
TRIGGER_PLATFORM,

View File

@ -54,11 +54,20 @@
---------------------------------------------------------------------- */
void CTeleportTrigger::collidedWith(CThing *_thisThing)
{
ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
switch( _thisThing->getThingType() )
{
case TYPE_PLAYER:
{
((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
PAUL_DBGMSG("HIT TELEPORT TRIGGER");
break;
}
default:
break;
}
}
/*===========================================================================

View File

@ -134,6 +134,8 @@ OutOfWater=5
GaryStart=6
FlameEmitter=7
IntermittentFlameEmitter=8
GaryStop=9
GaryGoLeft=10
################################################
# FX

View File

@ -23,4 +23,8 @@ HasBox=1
[FlameEmitter]
[IntermittentFlameEmitter]
[IntermittentFlameEmitter]
[GaryStop]
[GaryGoLeft]

View File

@ -1933,6 +1933,22 @@ SOURCE=..\..\..\source\triggers\tgarygo.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tggleft.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tggleft.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tgstop.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tgstop.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tifemit.cpp
# End Source File
# Begin Source File