From 54614d31dcebb2b1fc448e3b216c57ecbf403175 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 29 Oct 2023 18:11:54 -0500 Subject: [PATCH] Selection cursor for overworld map items. --- Crawler/Player.cpp | 4 ++++ Crawler/Player.h | 1 + Crawler/State_OverworldMap.cpp | 39 +++++++++++++++++++++++++++++++++- Crawler/State_OverworldMap.h | 1 + Crawler/Version.h | 2 +- 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 8e9cd668..04b62df8 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -714,4 +714,8 @@ void Player::RestoreMana(int amt){ void Player::ConsumeMana(int amt){ mana=std::clamp(mana-amt,0,maxmana); +} + +void Player::SetSizeMult(float size){ + this->size=size; } \ No newline at end of file diff --git a/Crawler/Player.h b/Crawler/Player.h index 52689ba6..4738beb5 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -114,6 +114,7 @@ public: int GetAttack(); float GetMoveSpdMult(); float GetSizeMult(); + void SetSizeMult(float size); float GetAttackRangeMult(); float GetSpinAngle(); State::State GetState(); diff --git a/Crawler/State_OverworldMap.cpp b/Crawler/State_OverworldMap.cpp index 22a4fcfc..7056ff7f 100644 --- a/Crawler/State_OverworldMap.cpp +++ b/Crawler/State_OverworldMap.cpp @@ -17,6 +17,7 @@ void State_OverworldMap::OnStateChange(GameState*prevState){ game->GetPlayer()->SetPos(currentConnectionPoint->rect.pos); game->GetPlayer()->UpdateWalkingAnimation(DOWN); game->GetPlayer()->SetState(State::FORCE_WALK); + game->GetPlayer()->SetSizeMult(1); }; void State_OverworldMap::OnUserUpdate(Crawler*game){ game->camera.SetTarget(currentConnectionPoint->rect.middle()); @@ -24,7 +25,43 @@ void State_OverworldMap::OnUserUpdate(Crawler*game){ game->GetPlayer()->Update(game->GetElapsedTime()); }; void State_OverworldMap::Draw(Crawler*game){ - + currentTime+=game->GetElapsedTime(); + for(ConnectionPoint&cp:connections){ + if(geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){ + float borderThickness=4; + vf2d crosshairExtension={std::min(0.25f*cp.rect.size.x-borderThickness/2,12.f),std::min(0.25f*cp.rect.size.y-borderThickness/2,12.f)}; + vf2d pulsatingAmt=vf2d{1,1}*std::abs(std::sin(currentTime*3))*2; + //Lower-Left Corner + vf2d pos=cp.rect.pos+vf2d{0,cp.rect.size.y-borderThickness}+vf2d{-pulsatingAmt.x,pulsatingAmt.y}; + vf2d size={borderThickness+crosshairExtension.x,borderThickness}; + game->view.FillRectDecal(pos,size,RED); + pos={pos.x,pos.y-crosshairExtension.y}+vf2d{-pulsatingAmt.x,pulsatingAmt.y}; + size={borderThickness,crosshairExtension.y}; + game->view.FillRectDecal(pos,size,RED); + //Lower-Right Corner + pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,cp.rect.size.y-borderThickness}+vf2d{pulsatingAmt.x,pulsatingAmt.y}; + size={borderThickness+crosshairExtension.x,borderThickness}; + game->view.FillRectDecal(pos,size,RED); + pos={pos.x+crosshairExtension.x,pos.y-crosshairExtension.y}+vf2d{pulsatingAmt.x,pulsatingAmt.y}; + size={borderThickness,crosshairExtension.y}; + game->view.FillRectDecal(pos,size,RED); + //Upper-Left Corner + pos=cp.rect.pos+vf2d{0,0}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y}; + size={borderThickness+crosshairExtension.x,borderThickness}; + game->view.FillRectDecal(pos,size,RED); + pos={pos.x,pos.y+borderThickness}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y}; + size={borderThickness,crosshairExtension.y}; + game->view.FillRectDecal(pos,size,RED); + //Upper-Right Corner + pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulsatingAmt.x,-pulsatingAmt.y}; + size={borderThickness+crosshairExtension.x,borderThickness}; + game->view.FillRectDecal(pos,size,RED); + pos={pos.x+crosshairExtension.x,pos.y+borderThickness}+vf2d{pulsatingAmt.x,-pulsatingAmt.y}; + size={borderThickness,crosshairExtension.y}; + game->view.FillRectDecal(pos,size,RED); + break; + } + } }; void State_OverworldMap::SetStageMarker(std::string connectionName){ for(ConnectionPoint&connection:connections){ diff --git a/Crawler/State_OverworldMap.h b/Crawler/State_OverworldMap.h index 7784f414..cee0b4e4 100644 --- a/Crawler/State_OverworldMap.h +++ b/Crawler/State_OverworldMap.h @@ -4,6 +4,7 @@ class State_OverworldMap:public GameState{ ConnectionPoint*currentConnectionPoint; + float currentTime; public: State_OverworldMap(); static std::vectorconnections; diff --git a/Crawler/Version.h b/Crawler/Version.h index fc6c74b2..79ac2171 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 2457 +#define VERSION_BUILD 2485 #define stringify(a) stringify_(a) #define stringify_(a) #a