Added burrow animation effect.

This commit is contained in:
sigonasr2 2024-08-21 18:00:48 -05:00
parent a3214adc77
commit 12432dd61a
3 changed files with 13 additions and 0 deletions

View File

@ -3937,6 +3937,7 @@
</tile> </tile>
<tile id="687" type="TileProps"> <tile id="687" type="TileProps">
<properties> <properties>
<property name="Solid" type="bool" value="true"/>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/> <property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties> </properties>
</tile> </tile>
@ -3954,6 +3955,7 @@
</tile> </tile>
<tile id="690" type="TileProps"> <tile id="690" type="TileProps">
<properties> <properties>
<property name="Solid" type="bool" value="true"/>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/> <property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties> </properties>
</tile> </tile>
@ -4534,6 +4536,7 @@
<tile id="835" type="TileProps"> <tile id="835" type="TileProps">
<properties> <properties>
<property name="Solid" type="bool" value="true"/> <property name="Solid" type="bool" value="true"/>
<property name="Terrain Type" type="int" propertytype="TerrainType" value="1"/>
</properties> </properties>
</tile> </tile>
<tile id="836" type="TileProps"> <tile id="836" type="TileProps">

View File

@ -129,6 +129,9 @@ void Hamster::UpdateHamsters(const float fElapsedTime){
}break; }break;
case BURROWING:{ case BURROWING:{
h.burrowTimer-=fElapsedTime; h.burrowTimer-=fElapsedTime;
h.burrowImgShrinkTimer-=fElapsedTime;
h.shrinkEffectColor=BLACK;
h.imgScale=std::max(0.f,util::lerp(0,1,h.burrowImgShrinkTimer*2.f));
if(h.burrowTimer<=0.f){ if(h.burrowTimer<=0.f){
h.burrowTimer=3.f; h.burrowTimer=3.f;
h.SetState(BURROW_WAIT); h.SetState(BURROW_WAIT);
@ -139,6 +142,8 @@ void Hamster::UpdateHamsters(const float fElapsedTime){
if(h.burrowTimer<=0.f){ if(h.burrowTimer<=0.f){
h.burrowTimer=1.f; h.burrowTimer=1.f;
h.SetState(SURFACING); h.SetState(SURFACING);
h.imgScale=0.f;
h.burrowImgShrinkTimer=0.5f;
} }
const Tunnel&enteredTunnel{HamsterGame::Game().GetTunnels().at(h.enteredTunnel)}; const Tunnel&enteredTunnel{HamsterGame::Game().GetTunnels().at(h.enteredTunnel)};
const vf2d destinationTunnelPos{HamsterGame::Game().GetTunnels().at(enteredTunnel.linkedTo).worldPos+vi2d{8,8}}; const vf2d destinationTunnelPos{HamsterGame::Game().GetTunnels().at(enteredTunnel.linkedTo).worldPos+vi2d{8,8}};
@ -146,6 +151,8 @@ void Hamster::UpdateHamsters(const float fElapsedTime){
}break; }break;
case SURFACING:{ case SURFACING:{
h.burrowTimer-=fElapsedTime; h.burrowTimer-=fElapsedTime;
h.burrowImgShrinkTimer-=fElapsedTime;
h.imgScale=std::min(1.f,util::lerp(1,0,h.burrowImgShrinkTimer*2.f));
vf2d targetDirVec{0.f,-16.f}; vf2d targetDirVec{0.f,-16.f};
const Tunnel&enteredTunnel{HamsterGame::Game().GetTunnels().at(h.enteredTunnel)}; const Tunnel&enteredTunnel{HamsterGame::Game().GetTunnels().at(h.enteredTunnel)};
const vf2d destinationTunnelPos{HamsterGame::Game().GetTunnels().at(enteredTunnel.linkedTo).worldPos+vi2d{8,8}}; const vf2d destinationTunnelPos{HamsterGame::Game().GetTunnels().at(enteredTunnel.linkedTo).worldPos+vi2d{8,8}};
@ -164,6 +171,7 @@ void Hamster::UpdateHamsters(const float fElapsedTime){
h.pos=walkOutTunnelDest.lerp(destinationTunnelPos,h.burrowTimer); h.pos=walkOutTunnelDest.lerp(destinationTunnelPos,h.burrowTimer);
if(h.burrowTimer<=0.f){ if(h.burrowTimer<=0.f){
h.SetState(Hamster::NORMAL); h.SetState(Hamster::NORMAL);
h.imgScale=1.f;
} }
}break; }break;
} }
@ -407,6 +415,7 @@ void Hamster::HandleCollision(){
SetState(Hamster::BURROWING); SetState(Hamster::BURROWING);
burrowTimer=1.f; burrowTimer=1.f;
enteredTunnel=id; enteredTunnel=id;
burrowImgShrinkTimer=0.5f;
} }
} }
} }

View File

@ -118,6 +118,7 @@ class Hamster{
float raceFinishAnimTimer{0.f}; float raceFinishAnimTimer{0.f};
std::pair<Timer,vf2d>collectedCheckpointInfo{INFINITY,{}}; std::pair<Timer,vf2d>collectedCheckpointInfo{INFINITY,{}};
float burrowTimer{}; float burrowTimer{};
float burrowImgShrinkTimer{};
uint16_t enteredTunnel{}; uint16_t enteredTunnel{};
public: public:
Hamster(const vf2d spawnPos,const std::string&img,const PlayerControlled IsPlayerControlled=NPC); Hamster(const vf2d spawnPos,const std::string&img,const PlayerControlled IsPlayerControlled=NPC);