Fix centering of camera for overworld map.

This commit is contained in:
2023-11-12 21:02:23 -06:00
parent c41ae8aaf9
commit bc07f58c9a
9 changed files with 32 additions and 18 deletions
+5 -5
View File
@@ -74,7 +74,7 @@ void State_OverworldMap::Draw(Crawler*game){
}
}
for(ConnectionPoint&cp:connections){
if(Unlock::IsUnlocked(cp)&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)){
if(Unlock::IsUnlocked(cp)&&geom2d::overlaps(game->GetWorldMousePos(),cp.rect)&&(&cp==currentConnectionPoint||cp.IsNeighbor(*currentConnectionPoint))){
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;
@@ -82,28 +82,28 @@ void State_OverworldMap::Draw(Crawler*game){
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=vf2d{pos.x,pos.y-crosshairExtension.y}+vf2d{-pulsatingAmt.x,pulsatingAmt.y};
pos=vf2d{pos.x,pos.y-crosshairExtension.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=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.y}+vf2d{pulsatingAmt.x,pulsatingAmt.y};
pos=vf2d{pos.x+crosshairExtension.x,pos.y-crosshairExtension.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=vf2d{pos.x,pos.y+borderThickness}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y};
pos=vf2d{pos.x,pos.y+borderThickness};
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=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness}+vf2d{pulsatingAmt.x,-pulsatingAmt.y};
pos=vf2d{pos.x+crosshairExtension.x,pos.y+borderThickness};
size={borderThickness,crosshairExtension.y};
game->view.FillRectDecal(pos,size,RED);
break;