diff --git a/makefile.gaz b/makefile.gaz index ce00938ba..657745ae9 100644 --- a/makefile.gaz +++ b/makefile.gaz @@ -189,7 +189,8 @@ system_src := main \ thing_src := thing -triggers_src := tlevexit +triggers_src := tlevexit \ + tlook utils_src := utils \ sincos \ diff --git a/source/level/level.cpp b/source/level/level.cpp index 25b6cfc00..344de590d 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -23,6 +23,10 @@ #include "triggers\tlevexit.h" #endif +#ifndef __TRIGGERS_TLOOK_H__ +#include "triggers\tlook.h" +#endif + #ifndef __PICKUPS_PICKUP_H__ #include "pickups\pickup.h" #endif @@ -620,19 +624,22 @@ sLvlHdr *LevelHdr=(sLvlHdr*)LevelBuffer; PAUL_DBGMSG("%d triggers",TriggerCount); for(int i=0;iType) { // Exit trigger case 0: - { - CLevelExitTrigger *exit; - exit=new ("LevelExitTrigger") CLevelExitTrigger(); - exit->init(); - exit->setExitPosition(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4, - TriggerList->Width<<4,TriggerList->Height<<4); + trigger=(CTriggerThing*)new ("LevelExitTrigger") CLevelExitTrigger(); + break; + + // Look down trigger + case 1: + trigger=(CTriggerThing*)new ("LookTrigger") CLookTrigger(); break; - } } + trigger->init(); + trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4, + TriggerList->Width<<4,TriggerList->Height<<4); TriggerList++; } } diff --git a/source/player/player.cpp b/source/player/player.cpp index ce9b6a9e1..952b41494 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -283,13 +283,15 @@ void CPlayer::shutdown() int looktimeout=20; -int lookmaxoffsetup=3*16; -int lookmaxoffsetdown=6*16; +int lookmaxoffsetup=3*MAP2D_BLOCKSTEPSIZE; +int lookmaxoffsetdown=6*MAP2D_BLOCKSTEPSIZE; int lookspeed=2; int lookreturnspeed=80; -int ledgexsearch=4; -int ledgemaxylook=4; +int ledgeTimer=25; +int ledgeSpeedIn=1; +int ledgeSpeedOut=3; +int ledgeShift=2; /*---------------------------------------------------------------------- Function: @@ -417,14 +419,65 @@ else if(Pos.vy>m_mapEdge.vy-64)Pos.vy=m_mapEdge.vy-64; } } + // Ledge look-ahead stuff + if(m_ledgeLookAhead&&m_ledgeLookAhead==m_lastLedgeLookAhead) + { + // timer.. + if(m_ledgeLookTimerlimit) + { + m_ledgeLookOffset=limit; + } + } + } + } + else + { + if(m_ledgeLookOffset>0) + { + m_ledgeLookOffset-=ledgeSpeedOut*_frames; + if(m_ledgeLookOffset<=0) + { + m_ledgeLookOffset=0; + m_ledgeLookTimer=0; + } + } + else if(m_ledgeLookOffset<0) + { + m_ledgeLookOffset+=ledgeSpeedOut*_frames; + if(m_ledgeLookOffset>=0) + { + m_ledgeLookOffset=0; + m_ledgeLookTimer=0; + } + } + } + m_lastLedgeLookAhead=m_ledgeLookAhead; + m_ledgeLookAhead=0; + + // Camera focus point stuff m_currentCamFocusPointTarget.vx=Pos.vx+MAP2D_CENTRE_X; - m_currentCamFocusPointTarget.vy=Pos.vy+MAP2D_CENTRE_Y; - m_currentCamFocusPoint.vx+=(m_currentCamFocusPointTarget.vx-m_currentCamFocusPoint.vx)>>cammove; - m_currentCamFocusPoint.vy+=(m_currentCamFocusPointTarget.vy-m_currentCamFocusPoint.vy)>>cammove; + m_currentCamFocusPointTarget.vy=Pos.vy+MAP2D_CENTRE_Y+(m_ledgeLookOffset>>ledgeShift); + for(i=0;i<_frames;i++) + { + m_currentCamFocusPoint.vx+=(m_currentCamFocusPointTarget.vx-m_currentCamFocusPoint.vx)>>cammove; + m_currentCamFocusPoint.vy+=(m_currentCamFocusPointTarget.vy-m_currentCamFocusPoint.vy)>>cammove; + } m_cameraPos.vx=m_currentCamFocusPoint.vx; m_cameraPos.vy=m_currentCamFocusPoint.vy+m_cameraLookOffset; + // Limit camera scroll to the edges of the map if(m_cameraPos.vx<0) { @@ -762,6 +815,9 @@ void CPlayer::respawn() m_currentCamFocusPoint.vx=Pos.vx+MAP2D_CENTRE_X; m_currentCamFocusPoint.vy=Pos.vy+MAP2D_CENTRE_Y; m_padLookAroundTimer=0; + m_ledgeLookAhead=m_lastLedgeLookAhead=0; + m_ledgeLookOffset=0; + m_ledgeLookTimer=0; m_glassesFlag=0; m_squeakyBootsTimer=0; diff --git a/source/player/player.h b/source/player/player.h index dc8392e98..902b0d932 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -161,6 +161,8 @@ public: int getHeightFromGround(int _x,int _y,int _maxHeight=32); int getHeightFromGroundNoPlatform(int _x,int _y,int _maxHeight=32); + void setLedgeLookAhead(int _lookAhead) {m_ledgeLookAhead=_lookAhead;} + void addHealth(int _health); void addLife(); ATTACK_STATE getAttackState(); @@ -210,6 +212,9 @@ private: DVECTOR m_currentCamFocusPoint; int m_facing; int m_padLookAroundTimer; + int m_ledgeLookAhead,m_lastLedgeLookAhead; + int m_ledgeLookOffset; + int m_ledgeLookTimer; enum diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index e4a99513b..373fc763b 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -726,17 +726,19 @@ void CThing::processEvent(GAME_EVENT _event,CThing *_sourceThing) // do nothing by default - ignore event } + /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ -/*void CThing::shove( DVECTOR move ) +void CTriggerThing::setPositionAndSize(int _x,int _y,int _w,int _h) { - Pos.vx += move.vx; - Pos.vy += move.vy; -}*/ + Pos.vx=_x+(_w/2); + Pos.vy=_y+(_h/2); + setCollisionSize(_w,_h); +} /*=========================================================================== end */ diff --git a/source/thing/thing.h b/source/thing/thing.h index 6dace492e..e5b3f8f59 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -111,7 +111,6 @@ public: DVECTOR getPos() {return Pos;} void setPos(DVECTOR newPos) {Pos=newPos;} DVECTOR getPosDelta() {return PosDelta;} - //virtual void shove(DVECTOR move); CThing *getNext() {return Next;} @@ -213,6 +212,7 @@ class CTriggerThing : public CThing { public: 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) }; diff --git a/source/triggers/tlevexit.cpp b/source/triggers/tlevexit.cpp index d9ba1f238..eb703eed2 100644 --- a/source/triggers/tlevexit.cpp +++ b/source/triggers/tlevexit.cpp @@ -87,20 +87,6 @@ void CLevelExitTrigger::render() } #endif -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -void CLevelExitTrigger::setExitPosition(int _x,int _y,int _w,int _h) -{ - Pos.vx=_x+(_w/2); - Pos.vy=_y+(_h/2); - setCollisionSize(_w,_h); -} - - /*---------------------------------------------------------------------- Function: Purpose: @@ -116,6 +102,5 @@ void CLevelExitTrigger::collidedWith(CThing *_thisThing) #endif } - /*=========================================================================== end */ diff --git a/source/triggers/tlevexit.h b/source/triggers/tlevexit.h index 925243700..9a81e3afe 100644 --- a/source/triggers/tlevexit.h +++ b/source/triggers/tlevexit.h @@ -40,7 +40,6 @@ public: #if defined (__USER_art__) || defined (__USER_sbart__) virtual void render(); #endif - void setExitPosition(int _x,int _y,int _w,int _h); protected: virtual void collidedWith(CThing *_thisThing); diff --git a/source/triggers/tlook.cpp b/source/triggers/tlook.cpp index 749c80b27..cc0a97f2a 100644 --- a/source/triggers/tlook.cpp +++ b/source/triggers/tlook.cpp @@ -21,6 +21,10 @@ #include "game\game.h" #endif +#ifndef __PLAYER_PLAYER_H__ +#include "player\player.h" +#endif + /* Std Lib ------- */ @@ -54,7 +58,7 @@ void CLookTrigger::collidedWith(CThing *_thisThing) { ASSERT(_thisThing->getThingType()==TYPE_PLAYER); - + GameScene.getPlayer()->setLedgeLookAhead(+4); } /*===========================================================================