From 121061f3b82bb608df874d3cb04fb2dc8212e93b Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Mon, 19 Aug 2024 14:13:50 -0500 Subject: [PATCH] Clean up Hamster Jet animations. Add hamster jet flame animations and rockets activate during movement. Refined Hamster Jet controls. --- HamsterJet.h | 42 ---------------------------- assets/hamster_jet.png | Bin 2369 -> 3791 bytes src/Hamster.cpp | 5 ++++ src/Hamster.h | 1 + src/HamsterGame.cpp | 3 +- src/HamsterGame.h | 2 +- src/HamsterJet.cpp | 62 +++++++++++++++++++++++++++++++++++++++-- src/HamsterJet.h | 13 +++++++++ 8 files changed, 82 insertions(+), 46 deletions(-) delete mode 100644 HamsterJet.h diff --git a/HamsterJet.h b/HamsterJet.h deleted file mode 100644 index 0d46c3f..0000000 --- a/HamsterJet.h +++ /dev/null @@ -1,42 +0,0 @@ -#pragma region License -/* -License (OLC-3) -~~~~~~~~~~~~~~~ - -Copyright 2024 Joshua Sigona - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions or derivations of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -2. Redistributions or derivative works in binary form must reproduce the above -copyright notice. This list of conditions and the following disclaimer must be -reproduced in the documentation and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its contributors may -be used to endorse or promote products derived from this software without specific -prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -SUCH DAMAGE. - -Portions of this software are copyright © 2024 The FreeType -Project (www.freetype.org). Please see LICENSE_FT.txt for more information. -All rights reserved. -*/ -#pragma endregion -#pragma once - -class HamsterJet{ - -}; \ No newline at end of file diff --git a/assets/hamster_jet.png b/assets/hamster_jet.png index f6c856ff4488f6072e09e6634ec63e19e65ae980..0c5994802d547399b3f9a729c2ce6ecb1694ca07 100644 GIT binary patch delta 3728 zcmZ8kcQo5y*#Fw2Y9wm31R+M1)~Fd`#0s@XZADdw>d%Z(LA6AyMo_yHtr4qcwTcpI z6tVXvMpZ*?eSiXlVhp%Kg8@z$aE7;lt+q$t_i29rG*K>%~hfP z>ao*;9=mp0OL#krRH9RFi+|`$Tie)Y#(p2f0cowDn}r^YTolI)`Qgyd&;dikO55P* z+qT`{w_uYEKg~tG@*dXa|D-3b{q9Z3G57(Fjv<(H_c-=;H)_GP`T8WUu3WH<-p#64 zk{nTaIEQP#VQOkK=0|a#+Hq*Q$3au$A;L#_B^%4-SC%EOLE-NbGPU;7y zf)ioC5r;EnW?7gVpCoFT+ylZ#^$uW8df>tB(SxeHwZ_1<+>^q9(^}CR2L{3U`Oo9S zTfOEN8}qwDT2@$ZoE8`~x*IxWXjL(Oc}rAW37?l5s9*gvI@`HUlaN=Q>K*<}+vN*# zVpDp1Kk#6GJ3Rn{sGs)vR^~0&MyWl$tDzne5CKF16OBud;-I=FWzv$?lJ7vQFWi<29 zVSf|0oBZZ)3th6vHx8=#TQ`=|gJj6kjDpmF`*OqEiJ9~WG_%COR%yJEafnkqgQ3l^ zutxCf(*A{RKD(Dt&}ar4iWBPZ9dG~aO*$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qZY{ zn{Gu=M1Iu@F>NaXoxwBV;%ty0QN&27$!7_`Gl3-viF1Jq`Nq8DOkr_hjbtU%8%?-48ziE!sh1bt;T|5Il87L? z6TmxW(rzgKYJq(XAriqP^TFR!jZFpqLPjS7|1^gGthnT%r@DsZ$!9-T@=6jNU@zra5lpWp+33e@hbRB5&gUd&fatAef8I-ZUI0__CkD44 zWXUe&b6vvf1IM>VbbXAHdSqaL<8bzw9f(iL5 z5lq?(DiNIP0GBS|{Co>g5FcAi-Ym!@E#w<`D2T4TU~AJGe<6IfQxy3oWQ6o3y@-g2 zh=_=Yh=_=Y2rmU0-fR@PPy4V{_k(6ja-q<+nN*XjtZ*_3wzp*8z*@fjNV zdHo5Ed@FxKnS`w$p#+hWA7xL%)qdGQL}I_JNl@7>e=CSc?G`-=YI{Wokr#VKO~RL* zqJqe)9p97iJ-+WCDkMmK87XRo`4YL%ZJOFx(Ps>`*rg;YR7T6nvZzEaHC1;tUUr?~ zDt-{fs;v{DRNA&d5LCM+uQRdHSK=f>eOGB36hS}E)j1dX%VJ${RN{HM%*m>}t(OH! zrM{rSJv&>qZDecal(),h.rot,wheelBottomImg.GetSourceRect().size/2,wheelBottomImg.GetSourceRect().pos,wheelBottomImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale)); + HamsterGame::Game().SetZ(h.z+0.005f); tv.DrawPartialRotatedDecal(h.pos,img.GetSourceImage()->Decal(),h.rot,img.GetSourceRect().size/2,img.GetSourceRect().pos,img.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale)); + HamsterGame::Game().SetZ(h.z+0.01f); if(h.HasPowerup(Powerup::WHEEL))tv.DrawPartialRotatedDecal(h.pos,wheelTopImg.GetSourceImage()->Decal(),h.rot,wheelTopImg.GetSourceRect().size/2,wheelTopImg.GetSourceRect().pos,wheelTopImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,{255,255,255,192},h.imgScale)); HamsterGame::Game().SetZ(0.f); } @@ -270,6 +272,7 @@ const float Hamster::GetTimeToMaxSpeed()const{ float finalTimeToMaxSpd{DEFAULT_TIME_TO_MAX_SPD}; if(!HasPowerup(Powerup::ICE)&&GetTerrainStandingOn()==Terrain::ICE)finalTimeToMaxSpd*=3; else if(!HasPowerup(Powerup::SWAMP)&&GetTerrainStandingOn()==Terrain::SWAMP)finalTimeToMaxSpd*=1.25; + if(state==FLYING)finalTimeToMaxSpd*=30.f; return finalTimeToMaxSpd; } const float Hamster::GetMaxSpeed()const{ @@ -296,12 +299,14 @@ const float Hamster::GetMaxSpeed()const{ }break; } if(HasPowerup(Powerup::WHEEL))finalMaxSpd*=1.5f; + if(state==FLYING)finalMaxSpd*=8.f; return finalMaxSpd; } const float Hamster::GetFriction()const{ float finalFriction{DEFAULT_FRICTION}; if(!HasPowerup(Powerup::ICE)&&GetTerrainStandingOn()==Terrain::ICE)finalFriction*=0.1f; else if(!HasPowerup(Powerup::SWAMP)&&GetTerrainStandingOn()==Terrain::SWAMP)finalFriction*=0.6f; + if(state==FLYING)finalFriction*=8.f; return finalFriction; } const float Hamster::GetTurnSpeed()const{ diff --git a/src/Hamster.h b/src/Hamster.h index 198c207..998b026 100644 --- a/src/Hamster.h +++ b/src/Hamster.h @@ -46,6 +46,7 @@ All rights reserved. #include "HamsterGame.h" class Hamster{ + friend class HamsterJet; enum PlayerControlled{ PLAYER_CONTROLLED=true, NPC=false, diff --git a/src/HamsterGame.cpp b/src/HamsterGame.cpp index bd6713b..1f24d1d 100644 --- a/src/HamsterGame.cpp +++ b/src/HamsterGame.cpp @@ -79,7 +79,7 @@ void HamsterGame::LoadAnimations(){ lavaAnimFrames.AddFrame(Animate2D::Frame{&GetGFX("gametiles.png"),{sourcePos,{16,16}}}); } LoadAnimation(JET_LIGHTS,"hamster_jet.png",{{0,48},{48,48}},0.3f,Animate2D::Style::Repeat,{48,48}); - + LoadAnimation(JET_FLAMES,"hamster_jet.png",{{48,0},{96,0}},0.15f,Animate2D::Style::Repeat,{48,48}); animatedWaterTile.Create(16,16,false,false); UpdateWaterTexture(); @@ -135,6 +135,7 @@ void HamsterGame::UpdateGame(const float fElapsedTime){ cloudOffset+=cloudSpd*fElapsedTime; camera.SetViewSize(tv.GetWorldVisibleArea()); camera.Update(fElapsedTime); + camera.SetLazyFollowRate(4.f*Hamster::GetPlayer().GetMaxSpeed()/128.f); tv.SetWorldOffset(tv.ScaleToWorld(-SCREEN_FRAME.pos)+camera.GetViewPosition()); Hamster::UpdateHamsters(fElapsedTime); Powerup::UpdatePowerups(fElapsedTime); diff --git a/src/HamsterGame.h b/src/HamsterGame.h index cbca8ff..f23906c 100644 --- a/src/HamsterGame.h +++ b/src/HamsterGame.h @@ -63,6 +63,7 @@ public: WHEEL_TOP, WHEEL_BOTTOM, JET_LIGHTS, + JET_FLAMES, }; HamsterGame(); @@ -109,7 +110,6 @@ private: GFX3D::PipeLine renderer; virtual void Apply3DTransform(std::vector&decals)override final; float zoom{1.f}; //Increase to zoom out, decrease to zoom in (this is the overhead distance from the player). - GFX3D::vec3d vUp{0,-1,0}; GFX3D::vec3d vEye{0.f,0,1}; GFX3D::vec3d vLookDir{0,0,-1}; diff --git a/src/HamsterJet.cpp b/src/HamsterJet.cpp index 4ba8bd5..1e86d57 100644 --- a/src/HamsterJet.cpp +++ b/src/HamsterJet.cpp @@ -49,14 +49,20 @@ void HamsterJet::Update(const float fElapsedTime){ jet.Update(fElapsedTime); lights.Update(fElapsedTime); timer=std::max(0.f,timer-fElapsedTime); + lastTappedSpace+=fElapsedTime; switch(state){ case SWOOP_DOWN:{ HamsterGame::Game().SetZoom(1.5f); z=util::lerp(0.f,3.f,std::pow(timer/3.f,2)); vf2d originalPos{hamster.GetPos().x-128.f,hamster.GetPos().y+32.f}; - pos=hamster.GetPos().lerp(originalPos,std::pow(timer/3.f,4)); if(timer<=0.4f){ hamster.SetPos(hamsterOriginalPos-vf2d{0.f,sin(float(geom2d::pi)*timer/0.4f)*8.f}); + hamster.SetZ(sin(float(geom2d::pi)*timer/0.4f)*0.2f); + jetState[TOP_LEFT]=OFF; + jetState[BOTTOM_LEFT]=OFF; + }else{ + jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=ON; + pos=hamster.GetPos().lerp(originalPos,std::pow(timer/3.f,4)); } if(timer<=0.f){ state=RISE_UP; @@ -68,22 +74,74 @@ void HamsterJet::Update(const float fElapsedTime){ } }break; case RISE_UP:{ + jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=ON; pos=targetPos.lerp(originalPos,std::sqrt(timer/3.f)); z=util::lerp(targetZ,0.f,timer/3.f); hamster.SetPos(pos); - hamster.SetZ(z+0.01f); + hamster.SetZ(z+0.03f); if(timer<=0.f){ state=PLAYER_CONTROL; HamsterGame::Game().SetZoom(1.f); } }break; + case PLAYER_CONTROL:{ + jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=OFF; + HandleJetControls(); + pos=hamster.GetPos(); + }break; } } void HamsterJet::Draw(){ HamsterGame::Game().SetZ(z); HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,jet.Decal(),0.f,{24,24},{},{48,48}); + const Animate2D::FrameSequence&flameAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_FLAMES)}; + const Animate2D::Frame&flameFrame{flameAnim.GetFrame(HamsterGame::Game().GetRuntime())}; + HamsterGame::Game().SetZ(z+0.01f); + if(jetState[TOP_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,flameFrame.GetSourceRect().size/2,flameFrame.GetSourceRect().pos+vf2d{0,0},flameFrame.GetSourceRect().size/2); + if(jetState[BOTTOM_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{24,0},flameFrame.GetSourceRect().pos+vf2d{0,24},flameFrame.GetSourceRect().size/2); + if(jetState[BOTTOM_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{0,0},flameFrame.GetSourceRect().pos+vf2d{24,24},flameFrame.GetSourceRect().size/2); + if(jetState[TOP_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{0,24},flameFrame.GetSourceRect().pos+vf2d{24,0},flameFrame.GetSourceRect().size/2); const Animate2D::FrameSequence&lightAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_LIGHTS)}; const Animate2D::Frame&lightFrame{lightAnim.GetFrame(HamsterGame::Game().GetRuntime())}; + HamsterGame::Game().SetZ(z+0.02f); HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,lights.Decal(),0.f,lightFrame.GetSourceRect().size/2.f,lightFrame.GetSourceRect().pos,lightFrame.GetSourceRect().size); HamsterGame::Game().SetZ(0.f); +} + +void HamsterJet::HandleJetControls(){ + lastTappedSpace+=HamsterGame::Game().GetElapsedTime(); + vf2d aimingDir{}; + if(HamsterGame::Game().GetKey(W).bHeld){ + aimingDir+=vf2d{0,-1}; + jetState[BOTTOM_RIGHT]=ON; + jetState[BOTTOM_LEFT]=ON; + } + if(HamsterGame::Game().GetKey(D).bHeld){ + aimingDir+=vf2d{1,0}; + jetState[BOTTOM_LEFT]=ON; + jetState[TOP_LEFT]=ON; + } + if(HamsterGame::Game().GetKey(S).bHeld){ + aimingDir+=vf2d{0,1}; + jetState[TOP_LEFT]=ON; + jetState[TOP_RIGHT]=ON; + } + if(HamsterGame::Game().GetKey(A).bHeld){ + aimingDir+=vf2d{-1,0}; + jetState[BOTTOM_RIGHT]=ON; + jetState[TOP_RIGHT]=ON; + } + if(aimingDir!=vf2d{}){ + hamster.targetRot=aimingDir.norm().polar().y; + const vf2d currentVel{hamster.vel}; + hamster.vel+=vf2d{currentVel.polar().x+(hamster.GetMaxSpeed()*HamsterGame::Game().GetElapsedTime())/hamster.GetTimeToMaxSpeed(),hamster.rot}.cart(); + hamster.vel=vf2d{std::min(hamster.GetMaxSpeed(),hamster.vel.polar().x),hamster.vel.polar().y}.cart(); + hamster.frictionEnabled=false; + } + if(HamsterGame::Game().GetKey(SPACE).bPressed){ + if(lastTappedSpace<=0.6f){ + state=LANDING; + } + lastTappedSpace=0.f; + } } \ No newline at end of file diff --git a/src/HamsterJet.h b/src/HamsterJet.h index e9c6c02..bb09b5d 100644 --- a/src/HamsterJet.h +++ b/src/HamsterJet.h @@ -50,6 +50,16 @@ class HamsterJet{ LANDING, COMPLETE_LANDING, }; + enum JetDirection{ + TOP_LEFT, + BOTTOM_LEFT, + BOTTOM_RIGHT, + TOP_RIGHT, + }; + enum JetState{ + ON=true, + OFF=false, + }; Hamster&hamster; vf2d pos; vf2d hamsterOriginalPos; @@ -61,8 +71,11 @@ class HamsterJet{ SpecialRenderable jet; SpecialRenderable lights; float timer{}; + std::arrayjetState; + float lastTappedSpace{}; public: HamsterJet(Hamster&hamster); void Update(const float fElapsedTime); void Draw(); + void HandleJetControls(); }; \ No newline at end of file