This commit is contained in:
Paul 2001-05-04 01:35:52 +00:00
parent 3e85e3fb21
commit 0700ee58fe
11 changed files with 69 additions and 22 deletions

View File

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

View File

@ -307,7 +307,7 @@ void CGameScene::initLevel()
m_player->init(); m_player->init();
m_player->setLayerCollision(Level.getCollisionLayer()); m_player->setLayerCollision(Level.getCollisionLayer());
DVECTOR mapSize=Level.getMapSize(); DVECTOR mapSize=Level.getMapSize();
CPlayer::CameraBox camBox={0,0,mapSize.vx,mapSize.vy}; CPlayer::CameraBox camBox={0,0,mapSize.vx<<4,mapSize.vy<<4};
m_player->setCameraBox(camBox); m_player->setCameraBox(camBox);
if(s_globalLevelSelectThing==1) if(s_globalLevelSelectThing==1)
{ {

View File

@ -31,6 +31,10 @@
#include "triggers\tteleprt.h" #include "triggers\tteleprt.h"
#endif #endif
#ifndef __TRIGGERS_TCAMLOCK_H__
#include "triggers\tcamlock.h"
#endif
#ifndef __PICKUPS_PICKUP_H__ #ifndef __PICKUPS_PICKUP_H__
#include "pickups\pickup.h" #include "pickups\pickup.h"
#endif #endif
@ -293,6 +297,28 @@ void CLevel::initLayers()
// Triggers // Triggers
// Yeah yeah - I'll put this crap into a seperate file when the numbers of trigger types get a bit bigger! (pkg) // 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));
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)
{
// Camera lock trigger
trigger=(CCameraLockTrigger*)new ("CameraLockTrigger") CCameraLockTrigger();
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++;
}
}
if (LevelHdr->TriggerList) if (LevelHdr->TriggerList)
{ {
sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList); sThingHdr *Hdr=(sThingHdr*)MakePtr(LevelHdr,LevelHdr->TriggerList);
@ -318,11 +344,19 @@ void CLevel::initLayers()
case 2: case 2:
trigger=(CTeleportTrigger*)new ("TeleportTrigger") CTeleportTrigger(); trigger=(CTeleportTrigger*)new ("TeleportTrigger") CTeleportTrigger();
break; break;
// Camera lock trigger
case 3:
trigger=NULL;
break;
}
if(trigger)
{
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);
} }
trigger->init();
trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4,
TriggerList->Width<<4,TriggerList->Height<<4);
trigger->setTargetPos(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4);
TriggerList++; TriggerList++;
} }
} }

View File

@ -546,7 +546,7 @@ void CPlayer::think(int _frames)
{ {
int i; int i;
if(m_healthType==HEALTH_TYPE__OUT_OF_WATER&&m_currentMode!=PLAYER_MODE_DEAD) if(m_healthType==HEALTH_TYPE__OUT_OF_WATER&&m_currentMode!=PLAYER_MODE_DEAD&&m_currentMode!=PLAYER_MODE_FLY)
{ {
m_healthWaterLevel-=waterDrainSpeed*_frames; m_healthWaterLevel-=waterDrainSpeed*_frames;
if(m_healthWaterLevel<=0) if(m_healthWaterLevel<=0)
@ -970,23 +970,15 @@ for(int i=0;i<NUM_LASTPOS;i++)
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CPlayer::setCameraBox(CameraBox _cameraBox) void CPlayer::setCameraBox(CameraBox _cameraBox)
{ {
_cameraBox.x1*=16;
_cameraBox.y1*=16;
_cameraBox.x2*=16;
_cameraBox.y2*=16;
//PAUL_DBGMSG("setCameraBox %d,%d %d,%d",_cameraBox.x1,_cameraBox.y1,_cameraBox.x2,_cameraBox.y2);
m_cameraPosLimitBox.x1=_cameraBox.x1; m_cameraPosLimitBox.x1=_cameraBox.x1;
m_cameraPosLimitBox.y1=_cameraBox.y1; m_cameraPosLimitBox.y1=_cameraBox.y1;
m_cameraPosLimitBox.x2=_cameraBox.x2-(32*MAP2D_BLOCKSTEPSIZE); // Made up numbers! :) (pkg); m_cameraPosLimitBox.x2=_cameraBox.x2-(32*MAP2D_BLOCKSTEPSIZE); // Made up numbers! :) (pkg);
m_cameraPosLimitBox.y2=_cameraBox.y2-(16*MAP2D_BLOCKSTEPSIZE); m_cameraPosLimitBox.y2=_cameraBox.y2-(16*MAP2D_BLOCKSTEPSIZE);
//PAUL_DBGMSG("m_cameraPosLimitBox %d,%d %d,%d",m_cameraPosLimitBox.x1,m_cameraPosLimitBox.y1,m_cameraPosLimitBox.x2,m_cameraPosLimitBox.y2);
m_playerPosLimitBox.x1=_cameraBox.x1+64; m_playerPosLimitBox.x1=_cameraBox.x1+64;
m_playerPosLimitBox.y1=_cameraBox.y1+64; m_playerPosLimitBox.y1=_cameraBox.y1+64;
m_playerPosLimitBox.x2=_cameraBox.x2-64; m_playerPosLimitBox.x2=_cameraBox.x2-64;
m_playerPosLimitBox.y2=_cameraBox.y2-64; m_playerPosLimitBox.y2=_cameraBox.y2-64;
//PAUL_DBGMSG("m_playerPosLimitBox %d,%d %d,%d",m_playerPosLimitBox.x1,m_playerPosLimitBox.y1,m_playerPosLimitBox.x2,m_playerPosLimitBox.y2);
} }
@ -1179,6 +1171,9 @@ void CPlayer::teleportTo(int _x,int _y)
{ {
DVECTOR pos={_x,_y}; DVECTOR pos={_x,_y};
CameraBox releaseCamBox={0,0,29999,29999};
setCameraBox(releaseCamBox);
setPos(pos); setPos(pos);
setRespawnPos(pos); setRespawnPos(pos);

View File

@ -881,10 +881,12 @@ void CTriggerThing::setPositionAndSize(int _x,int _y,int _w,int _h)
Params: Params:
Returns: Returns:
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CTriggerThing::setTargetPos(int _x,int _y) void CTriggerThing::setTargetBox(int _x,int _y,int _w,int _h)
{ {
TargetPos.vx=_x; m_boxX1=_x;
TargetPos.vy=_y; m_boxY1=_y;
m_boxX2=_x+_w;
m_boxY2=_y+_h;
} }
/*=========================================================================== /*===========================================================================

View File

@ -216,8 +216,9 @@ class CTriggerThing : public CThing
public: public:
virtual TYPE getThingType() {return TYPE_TRIGGER;} 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 setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg)
virtual void setTargetPos(int _x,int _y); // 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)
DVECTOR TargetPos; protected:
int m_boxX1,m_boxY1,m_boxX2,m_boxY2;
}; };
class CHazardThing : public CThing class CHazardThing : public CThing
{ {

View File

@ -53,9 +53,13 @@
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
void CCameraLockTrigger::collidedWith(CThing *_thisThing) void CCameraLockTrigger::collidedWith(CThing *_thisThing)
{ {
CPlayer::CameraBox camBox={m_boxX1,m_boxY1,m_boxX2,m_boxY2};
ASSERT(_thisThing->getThingType()==TYPE_PLAYER); ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
// ((CPlayer*)_thisThing)->teleportTo(TargetPos.vx+8,TargetPos.vy+16); ((CPlayer*)_thisThing)->setCameraBox(camBox);
PAUL_DBGMSG("HIT CAM BOX TRIGGER");
} }
/*=========================================================================== /*===========================================================================

View File

@ -55,7 +55,9 @@ void CTeleportTrigger::collidedWith(CThing *_thisThing)
{ {
ASSERT(_thisThing->getThingType()==TYPE_PLAYER); ASSERT(_thisThing->getThingType()==TYPE_PLAYER);
((CPlayer*)_thisThing)->teleportTo(TargetPos.vx+8,TargetPos.vy+16); ((CPlayer*)_thisThing)->teleportTo(m_boxX1+8,m_boxY1+16);
PAUL_DBGMSG("HIT TELEPORT TRIGGER");
} }
/*=========================================================================== /*===========================================================================

View File

@ -1605,6 +1605,14 @@ SOURCE=..\..\..\source\thing\thing.h
# PROP Default_Filter "" # PROP Default_Filter ""
# Begin Source File # Begin Source File
SOURCE=..\..\..\source\triggers\tcamlock.cpp
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tcamlock.h
# End Source File
# Begin Source File
SOURCE=..\..\..\source\triggers\tlevexit.cpp SOURCE=..\..\..\source\triggers\tlevexit.cpp
# End Source File # End Source File
# Begin Source File # Begin Source File