#pragma once #include "State_OverworldMap.h" #include "Crawler.h" #include "DEFINES.h" #include "Menu.h" INCLUDE_MONSTER_LIST INCLUDE_game std::vectorState_OverworldMap::connections; State_OverworldMap::State_OverworldMap(){ SetStageMarker("Stage I-I"); //Eventually we will load the game from a file and this will not be necessary. We just set it to this for now. } void State_OverworldMap::OnStateChange(GameState*prevState){ Menu::CloseAllMenus(); 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()); game->UpdateCamera(game->GetElapsedTime()); 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){ if(connection.name==connectionName){ currentConnectionPoint=&connection; return; } } std::cout<<"WARNING! Could not find a connection point with name "<