This commit is contained in:
Daveo 2001-05-29 20:31:02 +00:00
parent 86ca3a02db
commit 85fecdb6f2
22 changed files with 91 additions and 195 deletions

View file

@ -285,7 +285,8 @@ system_src := main \
thing_src := thing
triggers_src := tcamlock \
triggers_src := trigger \
tcamlock \
tlevexit \
tlook \
trestart \

View file

@ -19,6 +19,8 @@
#include "gfx\font.h"
#include "triggers\trigger.h"
/*
#ifndef __TRIGGERS_TLEVEXIT_H__
#include "triggers\tlevexit.h"
#endif
@ -38,6 +40,7 @@
#ifndef __TRIGGERS_TWATER_H__
#include "triggers\twater.h"
#endif
*/
#ifndef __PICKUPS_PICKUP_H__
#include "pickups\pickup.h"
@ -352,79 +355,28 @@ void CLevel::initLayers()
/*****************************************************************************/
void CLevel::initThings(int _respawningLevel)
{
// Triggers
// Yeah yeah - I'll put this crap into a seperate file when the numbers of trigger types get a bit bigger! (pkg)
if (LevelHdr->TriggerList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
TriggerCount=Hdr->Count;
TriggerList=(sThingTrigger*)MakePtr(Hdr,sizeof(sThingHdr));
// Cam Locks first
for(int i=0;i<TriggerCount;i++)
{
CTriggerThing *trigger=NULL; // I hate having to do this just to keep the compiler quiet :/ (pkg)
if(TriggerList->Type==3)
if (TriggerList[i].Type==CTrigger::TRIGGER_CAMLOCK)
{
// Camera lock trigger
trigger=(CCameraLockTrigger*)new ("CameraLockTrigger") CCameraLockTrigger();
trigger->setThingSubType(0);
trigger->init();
trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4,
TriggerList->Width<<4,TriggerList->Height<<4);
trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4);
CTrigger::Create(&TriggerList[i]);
}
TriggerList++;
}
}
if (LevelHdr->TriggerList)
{
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
TriggerCount=Hdr->Count;
// the rest
TriggerList=(sThingTrigger*)MakePtr(Hdr,sizeof(sThingHdr));
for(int i=0;i<TriggerCount;i++)
{
CTriggerThing *trigger=NULL; // I hate having to do this just to keep the compiler quiet :/ (pkg)
switch(TriggerList->Type)
if (TriggerList[i].Type!=CTrigger::TRIGGER_CAMLOCK)
{
// Exit trigger
case 0:
trigger=(CTriggerThing*)new ("LevelExitTrigger") CLevelExitTrigger();
break;
// Level respawn trigger
case 1:
trigger=(CRestartPointTrigger*)new ("RestartTrigger") CRestartPointTrigger();
break;
// Teleport trigger
case 2:
trigger=(CTeleportTrigger*)new ("TeleportTrigger") CTeleportTrigger();
break;
// Camera lock trigger
case 3:
trigger=NULL;
break;
// In/Out of water triggers
case 4:
trigger=(CInWaterTrigger*)new ("InWaterTrigger") CInWaterTrigger();
break;
case 5:
trigger=(COutOfWaterTrigger*)new ("OutOfWaterTrigger") COutOfWaterTrigger();
break;
CTrigger::Create(&TriggerList[i]);
}
if(trigger)
{
trigger->setThingSubType(0);
trigger->init();
trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4,
TriggerList->Width<<4,TriggerList->Height<<4);
trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4);
}
TriggerList++;
}
}

View file

@ -20,7 +20,7 @@
#endif
/*****************************************************************************/
#define LListLen (32*2)
#define LListLen (256)
/*****************************************************************************/
typedef struct

View file

@ -15,6 +15,8 @@
#include "platform\prbridge.h"
#endif
#include "triggers\trigger.h"
#ifndef __TRIGGERS_TPLATFRM_H__
#include "triggers\tplatfrm.h"
#endif

View file

@ -38,6 +38,7 @@
#include "projectl\projectl.h"
#include "enemy\npc.h"
#include "friend\friend.h"
#include "triggers\trigger.h"
#include "fx\fx.h"
#ifndef __FRIEND_FRIEND_H__
@ -115,7 +116,7 @@ static const sFreeListTable FreeListTable[]=
/* 4*/ {CThing::TYPE_NPC ,CNpcFriend::MAX_SUBTYPE},
/* 5*/ {CThing::TYPE_ENEMY ,CNpcEnemy::MAX_SUBTYPE},
/* 6*/ {CThing::TYPE_ENEMYPROJECTILE ,CProjectile::MAX_SUBTYPE},
/* 7*/ {CThing::TYPE_TRIGGER ,CTriggerThing::MAX_SUBTYPE},
/* 7*/ {CThing::TYPE_TRIGGER ,CTrigger::MAX_SUBTYPE},
/* 8*/ {CThing::TYPE_HAZARD ,CNpcHazard::MAX_SUBTYPE},
/* 9*/ {CThing::TYPE_FX ,CFX::MAX_SUBTYPE},
};
@ -837,6 +838,8 @@ CThing *CThingManager::GetThing(int Type,int SubType)
CThing **List=s_FreeList[Type];
CThing *Thing=List[SubType];
ASSERT(Type<CThing::MAX_TYPE);
ASSERT(SubType<FreeListTable[Type].Count);
if (Thing)
{
List[SubType]=Thing->NextFreeThing;
@ -898,6 +901,7 @@ void CThing::init()
{
ParentThing=NULL;
NextThing=NULL;
NextFreeThing=0;
m_numChildren = 0;
Pos.vx=Pos.vy=10;
@ -1012,78 +1016,6 @@ void CThing::ShowBBox()
DrawLine(area.x1,area.y1,area.x2,area.y2,255,0,0,0);
DrawLine(area.x2,area.y1,area.x1,area.y2,255,0,0,0);
}
/*
DVECTOR ofs;
CRECT area;
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)
{
area=getCollisionArea();
SVECTOR points[4];
VECTOR vecPoints[4];
points[0].vx = area.x1 - Pos.vx;
points[0].vy = area.y1 - Pos.vy;
points[1].vx = area.x1 - Pos.vx;
points[1].vy = area.y2 - Pos.vy;
points[2].vx = area.x2 - Pos.vx;
points[2].vy = area.y2 - Pos.vy;
points[3].vx = area.x2 - Pos.vx;
points[3].vy = area.y1 - Pos.vy;
MATRIX mtx;
SetIdentNoTrans(&mtx );
RotMatrixZ( m_collisionAngle, &mtx );
ApplyMatrix( &mtx, &points[0], &vecPoints[0] );
ApplyMatrix( &mtx, &points[1], &vecPoints[1] );
ApplyMatrix( &mtx, &points[2], &vecPoints[2] );
ApplyMatrix( &mtx, &points[3], &vecPoints[3] );
vecPoints[0].vx += Pos.vx - ofs.vx;
vecPoints[0].vy += Pos.vy - ofs.vy;
vecPoints[1].vx += Pos.vx - ofs.vx;
vecPoints[1].vy += Pos.vy - ofs.vy;
vecPoints[2].vx += Pos.vx - ofs.vx;
vecPoints[2].vy += Pos.vy - ofs.vy;
vecPoints[3].vx += Pos.vx - ofs.vx;
vecPoints[3].vy += Pos.vy - ofs.vy;
//DrawLine(area.x1,area.y1,area.x1,area.y2,255,255,255,0);
//DrawLine(area.x1,area.y2,area.x2,area.y2,255,255,255,0);
//DrawLine(area.x2,area.y2,area.x2,area.y1,255,255,255,0);
//DrawLine(area.x2,area.y1,area.x1,area.y1,255,255,255,0);
DrawLine( vecPoints[0].vx, vecPoints[0].vy, vecPoints[1].vx, vecPoints[1].vy,255,255,255,0);
DrawLine( vecPoints[1].vx, vecPoints[1].vy, vecPoints[2].vx, vecPoints[2].vy,255,255,255,0);
DrawLine( vecPoints[2].vx, vecPoints[2].vy, vecPoints[3].vx, vecPoints[3].vy,255,255,255,0);
DrawLine( vecPoints[3].vx, vecPoints[3].vy, vecPoints[0].vx, vecPoints[0].vy,255,255,255,0);
area.x1=Pos.vx-10-ofs.vx;
area.y1=Pos.vy-10-ofs.vy;
area.x2=Pos.vx+10-ofs.vx;
area.y2=Pos.vy+10-ofs.vy;
DrawLine(area.x1,area.y1,area.x2,area.y2,255,0,0,0);
DrawLine(area.x2,area.y1,area.x1,area.y2,255,0,0,0);
}
*/
}
}
#endif
@ -1207,17 +1139,7 @@ CThing *List=NextThing;
Params:
Returns:
---------------------------------------------------------------------- */
int CThing::getNumChildren()
{
return( m_numChildren );
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
/*
bool CThing::hasChild(CThing *Child)
{
CThing *nextChild = NextThing;
@ -1234,7 +1156,7 @@ CThing *nextChild = NextThing;
return( false );
}
*/
/*----------------------------------------------------------------------
Function:
Purpose:
@ -1370,25 +1292,3 @@ void CThing::processEvent(GAME_EVENT _event,CThing *_sourceThing)
Params:
Returns:
---------------------------------------------------------------------- */
void CTriggerThing::setPositionAndSize(int _x,int _y,int _w,int _h)
{
Pos.vx=_x+(_w/2);
Pos.vy=_y+(_h/2);
setCollisionSize(_w,_h);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CTriggerThing::setTargetBox(int _x,int _y,int _w,int _h)
{
m_boxX1=_x;
m_boxY1=_y;
m_boxX2=_x+_w;
m_boxY2=_y+_h;
}

View file

@ -149,8 +149,8 @@ virtual int dontKillDuringLevelRespawn() {return false;}
void removeChild(CThing *Child);
void removeAllChild();
void deleteAllChild();
bool hasChild(CThing *Child);
int getNumChildren();
// bool hasChild(CThing *Child);
int getNumChildren() {return( m_numChildren );}
DVECTOR const &getPos() {return Pos;}
@ -286,17 +286,7 @@ virtual TYPE getThingType() {return TYPE_PLATFORM;}
class CTriggerThing : public CThing
{
public:
enum
{ // For Dynamic ThingCache
MAX_SUBTYPE =1,
};
virtual TYPE getThingType() {return TYPE_TRIGGER;}
virtual void setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
virtual void setTargetBox(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
protected:
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
};
class CHazardThing : public CThing

View file

@ -15,6 +15,8 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tcamlock.h"
#ifndef __PLAYER_PLAYER_H__

View file

@ -34,7 +34,7 @@
Structure defintions
-------------------- */
class CCameraLockTrigger : public CTriggerThing
class CCameraLockTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tlevexit.h"
#ifndef __GAME_GAME_H__

View file

@ -34,7 +34,7 @@
Structure defintions
-------------------- */
class CLevelExitTrigger : public CTriggerThing
class CLevelExitTrigger : public CTrigger
{
public:
#if defined (__USER_art__) || defined (__USER_sbart__)

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tlook.h"
#ifndef __PLAYER_PLAYER_H__

View file

@ -34,7 +34,7 @@
Structure defintions
-------------------- */
class CLookTrigger : public CTriggerThing
class CLookTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tplatfrm.h"
#ifndef __GAME_GAME_H__

View file

@ -38,7 +38,7 @@
Structure defintions
-------------------- */
class CPlatformTrigger : public CTriggerThing
class CPlatformTrigger : public CTrigger
{
public:
#if defined (__USER_art__) || defined (__USER_sbart__)

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\trestart.h"
#ifndef __PLAYER_PLAYER_H__

View file

@ -34,7 +34,7 @@
Structure defintions
-------------------- */
class CRestartPointTrigger : public CTriggerThing
class CRestartPointTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);

View file

@ -44,7 +44,7 @@
CTrigger *CTrigger::Create(int Type)
{
CTrigger *trigger;
printf("Trig Type %i\n",Type);
trigger = (CTrigger*)CThingManager::GetThing(CThing::TYPE_TRIGGER,Type);
if (!trigger)
switch( Type )
@ -66,20 +66,19 @@ printf("Trig Type %i\n",Type);
// Camera lock trigger
case TRIGGER_CAMLOCK:
trigger=NULL;
trigger=(CCameraLockTrigger*)new ("CameraLockTrigger") CCameraLockTrigger();
break;
// In/Out of water triggers
case TRIGGER_WATER:
case TRIGGER_INWATER:
trigger=(CInWaterTrigger*)new ("InWaterTrigger") CInWaterTrigger();
break;
case 5:
case TRIGGER_OUTWATER:
trigger=(COutOfWaterTrigger*)new ("OutOfWaterTrigger") COutOfWaterTrigger();
break;
default:
trigger=NULL;
}
printf("TriggerDone\n");
ASSERT( trigger);
trigger->setThingSubType(Type);
@ -92,7 +91,6 @@ printf("TriggerDone\n");
CTrigger *CTrigger::Create(sThingTrigger *ThisTrigger)
{
CTrigger *trigger=Create(ThisTrigger->Type);
trigger->setPositionAndSize(ThisTrigger->Pos.X<<4,ThisTrigger->Pos.Y<<4,ThisTrigger->Width<<4,ThisTrigger->Height<<4);
trigger->setTargetBox(ThisTrigger->TargetPos.X<<4,ThisTrigger->TargetPos.Y<<4,ThisTrigger->TargetSize.X<<4,ThisTrigger->TargetSize.Y<<4);
@ -102,9 +100,47 @@ CTrigger *trigger=Create(ThisTrigger->Type);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::init()
{
CTriggerThing::init();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::shutdown()
{
CTriggerThing::shutdown();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::think(int _frames)
{
CTriggerThing::think(_frames);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::render()
{
CTriggerThing::render();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void CTrigger::setPositionAndSize(int _x,int _y,int _w,int _h)
{
Pos.vx=_x+(_w/2);
Pos.vy=_y+(_h/2);
setCollisionSize(_w,_h);
}
/*----------------------------------------------------------------------
Function:
Purpose:
Params:
Returns:
---------------------------------------------------------------------- */
void CTrigger::setTargetBox(int _x,int _y,int _w,int _h)
{
m_boxX1=_x;
m_boxY1=_y;
m_boxX2=_x+_w;
m_boxY2=_y+_h;
}

View file

@ -3,9 +3,9 @@
trigger.h
Author: dave
Created:
Created: cos paul was too lazy
Project: Spongebob
Purpose:
Purpose: Oh, cos I like the sound of my own typing
Copyright (c) 2001 Climax Development Ltd
@ -27,7 +27,8 @@ enum TRIGGER_TYPE
TRIGGER_RESPAWN,
TRIGGER_TELEPORT,
TRIGGER_CAMLOCK,
TRIGGER_WATER,
TRIGGER_INWATER,
TRIGGER_OUTWATER,
TRIGGER_MAX,
};
@ -38,13 +39,19 @@ enum TRIGGER_TYPE
virtual void init();
virtual void shutdown();
virtual void think(int _frames);
virtual void render();
static CTrigger *Create(int Type);
static CTrigger *Create(sThingTrigger *ThisTrigger);
virtual void setPositionAndSize(int _x,int _y,int _w,int _h);
virtual void setTargetBox(int _x,int _y,int _w,int _h);
protected:
virtual void collidedWith(CThing *_thisThing){};
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
};
#endif

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\tteleprt.h"
#ifndef __PLAYER_PLAYER_H__

View file

@ -34,7 +34,7 @@
Structure defintions
-------------------- */
class CTeleportTrigger : public CTriggerThing
class CTeleportTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);

View file

@ -15,6 +15,7 @@
Includes
-------- */
#include "triggers\trigger.h"
#include "triggers\twater.h"
#ifndef __PLAYER_PLAYER_H__

View file

@ -34,14 +34,14 @@
Structure defintions
-------------------- */
class CInWaterTrigger : public CTriggerThing
class CInWaterTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);
};
class COutOfWaterTrigger : public CTriggerThing
class COutOfWaterTrigger : public CTrigger
{
protected:
virtual void collidedWith(CThing *_thisThing);