mirror of
https://github.com/sigonasr2/hamster.git
synced 2025-04-18 06:39:39 -05:00
Make Checkpoint hashes use 64-bit values. Remove manual updating of tiling water texture.
This commit is contained in:
parent
fd6d186fb6
commit
baf7ca769c
@ -62,7 +62,7 @@ public:
|
||||
template <>
|
||||
struct std::hash<Checkpoint>
|
||||
{
|
||||
std::size_t operator()(const Checkpoint&checkpoint)const
|
||||
int_fast64_t operator()(const Checkpoint&checkpoint)const
|
||||
{
|
||||
return (int_fast64_t)(*(int_fast32_t*)(&checkpoint.pos.x))<<32|*(int_fast32_t*)(&checkpoint.pos.y);
|
||||
}
|
||||
|
@ -38,6 +38,16 @@ bool HamsterGame::OnUserCreate(){
|
||||
radarCircle.push_back(vf2d{cos(angle),sin(angle)}*43+vf2d{43,44});
|
||||
}
|
||||
radar=ViewPort{radarCircle,{5.f,8.f}};
|
||||
|
||||
for(int i:std::ranges::iota_view(0,8)){
|
||||
waterTiles.emplace_back();
|
||||
Renderable&waterTile{waterTiles.back()};
|
||||
waterTile.Create(16,16,false,false);
|
||||
SetDrawTarget(waterTile.Sprite());
|
||||
DrawPartialSprite({},GetGFX("gametiles.png").Sprite(),{192+i*16,784},{16,16});
|
||||
SetDrawTarget(nullptr);
|
||||
waterTile.Decal()->Update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -104,8 +114,6 @@ void HamsterGame::LoadAnimations(){
|
||||
LoadAnimation(AnimationState::DEFAULT,"checkpoint.png",{{}},0.f,Animate2D::Style::OneShot,{128,128});
|
||||
LoadAnimation(AnimationState::CHECKPOINT_CYCLING,"checkpoint.png",{{},{128,0}},0.4f,Animate2D::Style::Repeat,{128,128});
|
||||
LoadAnimation(AnimationState::CHECKPOINT_COLLECTED,"checkpoint.png",{{128,0}},0.f,Animate2D::Style::OneShot,{128,128});
|
||||
animatedWaterTile.Create(16,16,false,false);
|
||||
UpdateWaterTexture();
|
||||
}
|
||||
|
||||
void HamsterGame::LoadLevel(const std::string&mapName){
|
||||
@ -167,7 +175,6 @@ void HamsterGame::UpdateGame(const float fElapsedTime){
|
||||
}else if(GetMouseWheel()<0){
|
||||
radarScale=std::clamp(radarScale*2.f,6.f,96.f);
|
||||
}
|
||||
UpdateWaterTexture();
|
||||
cloudOffset+=cloudSpd*fElapsedTime;
|
||||
camera.SetViewSize(tv.GetWorldVisibleArea());
|
||||
camera.Update(fElapsedTime);
|
||||
@ -182,7 +189,8 @@ void HamsterGame::UpdateGame(const float fElapsedTime){
|
||||
|
||||
void HamsterGame::DrawGame(){
|
||||
SetZ(-0.01f);
|
||||
tv.DrawPartialDecal({-3200,-3200},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{6400,6400},animatedWaterTile.Decal(),{0,0},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{6400,6400});
|
||||
const size_t waterTileInd{size_t(GetRuntime()/0.2f)};
|
||||
tv.DrawPartialDecal({-3200,-3200},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{6400,6400},waterTiles[waterTileInd%waterTiles.size()].Decal(),{0,0},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{6400,6400});
|
||||
SetZ(-0.0005f);
|
||||
DrawLevelTiles();
|
||||
Checkpoint::DrawCheckpoints(tv);
|
||||
@ -342,15 +350,6 @@ const double HamsterGame::GetRuntime()const{
|
||||
return runTime;
|
||||
}
|
||||
|
||||
void HamsterGame::UpdateWaterTexture(){
|
||||
const Animate2D::FrameSequence&waterAnimSequence{ANIMATED_TILE_IDS[1384]};
|
||||
const Animate2D::Frame&frame{waterAnimSequence.GetFrame(GetRuntime())};
|
||||
SetDrawTarget(animatedWaterTile.Sprite());
|
||||
DrawPartialSprite({},frame.GetSourceImage()->Sprite(),frame.GetSourceRect().pos,frame.GetSourceRect().size);
|
||||
SetDrawTarget(nullptr);
|
||||
animatedWaterTile.Decal()->Update();
|
||||
}
|
||||
|
||||
void HamsterGame::Apply3DTransform(std::vector<DecalInstance>&decals){
|
||||
std::vector<DecalInstance>oldDecals;
|
||||
std::vector<DecalInstance>foregroundDecals;
|
||||
|
@ -67,7 +67,6 @@ public:
|
||||
bool OnUserCreate()override final;
|
||||
bool OnUserUpdate(float fElapsedTime)override final;
|
||||
bool OnUserDestroy()override final;
|
||||
|
||||
static const Renderable&GetGFX(const std::string&img);
|
||||
static const Animate2D::Animation<AnimationState::AnimationState>&GetAnimations(const std::string&img);
|
||||
static const Animate2D::FrameSequence&GetAnimation(const std::string&img,const AnimationState::AnimationState state);
|
||||
@ -99,8 +98,6 @@ private:
|
||||
Renderable mapImage;
|
||||
std::vector<Letter>activeLetters;
|
||||
float updatePixelsTimer;
|
||||
Renderable animatedWaterTile;
|
||||
void UpdateWaterTexture();
|
||||
GFX3D::PipeLine renderer;
|
||||
virtual void Apply3DTransform(std::vector<DecalInstance>&decals)override final;
|
||||
float zoom{1.f}; //Increase to zoom out, decrease to zoom in (this is the overhead distance from the player).
|
||||
@ -114,4 +111,5 @@ private:
|
||||
ViewPort radar;
|
||||
void DrawRadar();
|
||||
float radarScale{48.f};
|
||||
std::vector<Renderable>waterTiles;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user