Fix centering of camera for overworld map.

pull/28/head
sigonasr2 1 year ago
parent c41ae8aaf9
commit bc07f58c9a
  1. 11
      Crawler/ConnectionPoint.cpp
  2. 1
      Crawler/ConnectionPoint.h
  3. 8
      Crawler/Crawler.cpp
  4. 2
      Crawler/Crawler.vcxproj
  5. 12
      Crawler/Crawler.vcxproj.filters
  6. 0
      Crawler/OverworldDisplayWindow.cpp
  7. 10
      Crawler/State_OverworldMap.cpp
  8. 4
      Crawler/State_OverworldMap.h
  9. 2
      Crawler/Version.h

@ -0,0 +1,11 @@
#include "State_OverworldMap.h"
bool ConnectionPoint::IsNeighbor(ConnectionPoint&testPoint){
for(int neighbor:neighbors){
if(neighbor!=-1){
ConnectionPoint&neighborCp=State_OverworldMap::ConnectionPointFromIndex(neighbor);
if(&neighborCp==&testPoint)return true;
}
}
return false;
}

@ -11,4 +11,5 @@ struct ConnectionPoint{
:rect(rect),name(name),map(map),unlockCondition(unlockCondition){
neighbors.fill(-1);
}
bool IsNeighbor(ConnectionPoint&testPoint);
};

@ -387,15 +387,17 @@ void Crawler::HandleUserInput(float fElapsedTime){
void Crawler::UpdateCamera(float fElapsedTime){
lastWorldShakeAdjust=std::max(0.f,lastWorldShakeAdjust-fElapsedTime);
if(worldShakeTime-fElapsedTime>0){
if(worldShakeTime>0){
worldShakeTime-=fElapsedTime;
if(worldShakeTime<=0){
camera.SetTarget(player->GetPos());
}
if(lastWorldShakeAdjust==0){
lastWorldShakeAdjust=0.02;
worldShakeVel.x*=-1;
worldShakeVel.y*=-1;
}
worldShake=player->GetPos()+worldShakeVel;
}else{
camera.SetTarget(player->GetPos());
}
worldShakeTime=std::max(0.f,worldShakeTime-fElapsedTime);
camera.Update(fElapsedTime);

@ -323,6 +323,7 @@
<ClCompile Include="CharacterInfoWindow.cpp" />
<ClCompile Include="ChargedArrow.cpp" />
<ClCompile Include="ClassSelectionWindow.cpp" />
<ClCompile Include="ConnectionPoint.cpp" />
<ClCompile Include="Crawler.cpp" />
<ClCompile Include="DamageNumber.cpp" />
<ClCompile Include="Effect.cpp" />
@ -342,7 +343,6 @@
<ClCompile Include="MenuAnimatedIconButton.h" />
<ClCompile Include="MenuComponent.cpp" />
<ClCompile Include="Meteor.cpp" />
<ClCompile Include="OverworldDisplayWindow.cpp" />
<ClCompile Include="OverworldMapLevelWindow.cpp" />
<ClCompile Include="RunAway.cpp" />
<ClCompile Include="RunTowards.cpp" />

@ -105,9 +105,6 @@
<ClInclude Include="Bullet.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Ability.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Class.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -231,6 +228,9 @@
<ClInclude Include="Error.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Ability.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">
@ -386,12 +386,12 @@
<ClCompile Include="Unlock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="OverworldDisplayWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
<ClCompile Include="OverworldMapLevelWindow.cpp">
<Filter>Source Files\Interface</Filter>
</ClCompile>
<ClCompile Include="ConnectionPoint.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -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;

@ -5,7 +5,7 @@
class State_OverworldMap:public GameState{
friend class Crawler;
ConnectionPoint*currentConnectionPoint;
float currentTime;
float currentTime=0;
vf2d playerTargetPos;
const float playerMoveSpd=48.0;
public:
@ -13,7 +13,7 @@ public:
static std::vector<ConnectionPoint>connections;
static ConnectionPoint&GetCurrentConnectionPoint();
void SetStageMarker(std::string connectionName);
ConnectionPoint&ConnectionPointFromIndex(int ind);
static ConnectionPoint&ConnectionPointFromIndex(int ind);
virtual void OnStateChange(GameState*prevState)override;
virtual void OnUserUpdate(Crawler*game)override;
virtual void Draw(Crawler*game)override;

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 1
#define VERSION_BUILD 2718
#define VERSION_BUILD 2736
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save