diff --git a/source/player/player.cpp b/source/player/player.cpp index 1fb239a53..51fa3c3dc 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -103,6 +103,8 @@ m_animFrame=0; m_cameraOffsetTarget.vy=0; m_cameraOffset.vx=0; m_cameraOffset.vy=0; + m_cameraLookYOffset=0; + m_cameraLookTimer=0; m_lastPadInput=m_padInput=0; } @@ -237,6 +239,59 @@ Pos.vy=23*16+1;//16*15; { m_invincibleFrameCount--; } + + // Look around + int pad=getPadInputHeld(); + if(pad&PAD_UP) + { + if(m_cameraLookTimer<=-LOOKAROUND_DELAY) + { + m_cameraLookYOffset-=LOOKAROUND_SCROLLSPEED; + if(m_cameraLookYOffset<-LOOKAROUND_MAXSCROLL) + { + m_cameraLookYOffset=-LOOKAROUND_MAXSCROLL; + } + } + else + { + m_cameraLookTimer--; + } + } + else if(pad&PAD_DOWN) + { + if(m_cameraLookTimer>=LOOKAROUND_DELAY) + { + m_cameraLookYOffset+=LOOKAROUND_SCROLLSPEED; + if(m_cameraLookYOffset>LOOKAROUND_MAXSCROLL) + { + m_cameraLookYOffset=LOOKAROUND_MAXSCROLL; + } + } + else + { + m_cameraLookTimer++; + } + } + else + { + m_cameraLookTimer=0; + if(m_cameraLookYOffset<0) + { + m_cameraLookYOffset+=LOOKAROUND_RESETSPEED; + if(m_cameraLookYOffset>0) + { + m_cameraLookYOffset=0; + } + } + else if(m_cameraLookYOffset>0) + { + m_cameraLookYOffset-=LOOKAROUND_RESETSPEED; + if(m_cameraLookYOffset<0) + { + m_cameraLookYOffset=0; + } + } + } } @@ -307,7 +362,7 @@ DVECTOR CPlayer::getCameraPos() { DVECTOR cameraPos; cameraPos.vx=Pos.vx+m_cameraOffset.vx; - cameraPos.vy=Pos.vy+m_cameraOffset.vy; + cameraPos.vy=Pos.vy+m_cameraOffset.vy+m_cameraLookYOffset; return cameraPos; } diff --git a/source/player/player.h b/source/player/player.h index b4a63c09e..a52749713 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -182,6 +182,11 @@ private: { INVIBCIBLE_FRAMES__START=120, // Invincible for this many frames at start of life INVINCIBLE_FRAMES__HIT=25, // Invincible for this many frames after taking damage + + LOOKAROUND_DELAY=90, // Frames before look around starts + LOOKAROUND_SCROLLSPEED=2, // Speed to scroll at + LOOKAROUND_MAXSCROLL=60, // Maximum distance to scroll + LOOKAROUND_RESETSPEED=6, // Speed of scroll back when look around ended }; int m_invincibleFrameCount; @@ -194,6 +199,8 @@ private: DVECTOR m_cameraOffsetTarget; DVECTOR m_cameraOffset; + int m_cameraLookYOffset; + int m_cameraLookTimer; void updatePadInput(); virtual int readPadInput();