Fix centering of camera for overworld map.
This commit is contained in:
@@ -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){
|
:rect(rect),name(name),map(map),unlockCondition(unlockCondition){
|
||||||
neighbors.fill(-1);
|
neighbors.fill(-1);
|
||||||
}
|
}
|
||||||
|
bool IsNeighbor(ConnectionPoint&testPoint);
|
||||||
};
|
};
|
||||||
|
|||||||
+5
-3
@@ -387,15 +387,17 @@ void Crawler::HandleUserInput(float fElapsedTime){
|
|||||||
|
|
||||||
void Crawler::UpdateCamera(float fElapsedTime){
|
void Crawler::UpdateCamera(float fElapsedTime){
|
||||||
lastWorldShakeAdjust=std::max(0.f,lastWorldShakeAdjust-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){
|
if(lastWorldShakeAdjust==0){
|
||||||
lastWorldShakeAdjust=0.02;
|
lastWorldShakeAdjust=0.02;
|
||||||
worldShakeVel.x*=-1;
|
worldShakeVel.x*=-1;
|
||||||
worldShakeVel.y*=-1;
|
worldShakeVel.y*=-1;
|
||||||
}
|
}
|
||||||
worldShake=player->GetPos()+worldShakeVel;
|
worldShake=player->GetPos()+worldShakeVel;
|
||||||
}else{
|
|
||||||
camera.SetTarget(player->GetPos());
|
|
||||||
}
|
}
|
||||||
worldShakeTime=std::max(0.f,worldShakeTime-fElapsedTime);
|
worldShakeTime=std::max(0.f,worldShakeTime-fElapsedTime);
|
||||||
camera.Update(fElapsedTime);
|
camera.Update(fElapsedTime);
|
||||||
|
|||||||
@@ -323,6 +323,7 @@
|
|||||||
<ClCompile Include="CharacterInfoWindow.cpp" />
|
<ClCompile Include="CharacterInfoWindow.cpp" />
|
||||||
<ClCompile Include="ChargedArrow.cpp" />
|
<ClCompile Include="ChargedArrow.cpp" />
|
||||||
<ClCompile Include="ClassSelectionWindow.cpp" />
|
<ClCompile Include="ClassSelectionWindow.cpp" />
|
||||||
|
<ClCompile Include="ConnectionPoint.cpp" />
|
||||||
<ClCompile Include="Crawler.cpp" />
|
<ClCompile Include="Crawler.cpp" />
|
||||||
<ClCompile Include="DamageNumber.cpp" />
|
<ClCompile Include="DamageNumber.cpp" />
|
||||||
<ClCompile Include="Effect.cpp" />
|
<ClCompile Include="Effect.cpp" />
|
||||||
@@ -342,7 +343,6 @@
|
|||||||
<ClCompile Include="MenuAnimatedIconButton.h" />
|
<ClCompile Include="MenuAnimatedIconButton.h" />
|
||||||
<ClCompile Include="MenuComponent.cpp" />
|
<ClCompile Include="MenuComponent.cpp" />
|
||||||
<ClCompile Include="Meteor.cpp" />
|
<ClCompile Include="Meteor.cpp" />
|
||||||
<ClCompile Include="OverworldDisplayWindow.cpp" />
|
|
||||||
<ClCompile Include="OverworldMapLevelWindow.cpp" />
|
<ClCompile Include="OverworldMapLevelWindow.cpp" />
|
||||||
<ClCompile Include="RunAway.cpp" />
|
<ClCompile Include="RunAway.cpp" />
|
||||||
<ClCompile Include="RunTowards.cpp" />
|
<ClCompile Include="RunTowards.cpp" />
|
||||||
|
|||||||
@@ -105,9 +105,6 @@
|
|||||||
<ClInclude Include="Bullet.h">
|
<ClInclude Include="Bullet.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="Ability.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="Class.h">
|
<ClInclude Include="Class.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -231,6 +228,9 @@
|
|||||||
<ClInclude Include="Error.h">
|
<ClInclude Include="Error.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Ability.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Player.cpp">
|
<ClCompile Include="Player.cpp">
|
||||||
@@ -386,12 +386,12 @@
|
|||||||
<ClCompile Include="Unlock.cpp">
|
<ClCompile Include="Unlock.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="OverworldDisplayWindow.cpp">
|
|
||||||
<Filter>Source Files\Interface</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="OverworldMapLevelWindow.cpp">
|
<ClCompile Include="OverworldMapLevelWindow.cpp">
|
||||||
<Filter>Source Files\Interface</Filter>
|
<Filter>Source Files\Interface</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="ConnectionPoint.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="cpp.hint" />
|
<None Include="cpp.hint" />
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ void State_OverworldMap::Draw(Crawler*game){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ConnectionPoint&cp:connections){
|
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;
|
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 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;
|
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 pos=cp.rect.pos+vf2d{0,cp.rect.size.y-borderThickness}+vf2d{-pulsatingAmt.x,pulsatingAmt.y};
|
||||||
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
|
vf2d size={borderThickness+crosshairExtension.x,borderThickness};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
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};
|
size={borderThickness,crosshairExtension.y};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
game->view.FillRectDecal(pos,size,RED);
|
||||||
//Lower-Right Corner
|
//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};
|
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};
|
size={borderThickness+crosshairExtension.x,borderThickness};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
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};
|
size={borderThickness,crosshairExtension.y};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
game->view.FillRectDecal(pos,size,RED);
|
||||||
//Upper-Left Corner
|
//Upper-Left Corner
|
||||||
pos=cp.rect.pos+vf2d{0,0}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y};
|
pos=cp.rect.pos+vf2d{0,0}+vf2d{-pulsatingAmt.x,-pulsatingAmt.y};
|
||||||
size={borderThickness+crosshairExtension.x,borderThickness};
|
size={borderThickness+crosshairExtension.x,borderThickness};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
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};
|
size={borderThickness,crosshairExtension.y};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
game->view.FillRectDecal(pos,size,RED);
|
||||||
//Upper-Right Corner
|
//Upper-Right Corner
|
||||||
pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulsatingAmt.x,-pulsatingAmt.y};
|
pos=cp.rect.pos+vf2d{cp.rect.size.x-borderThickness-crosshairExtension.x,0}+vf2d{pulsatingAmt.x,-pulsatingAmt.y};
|
||||||
size={borderThickness+crosshairExtension.x,borderThickness};
|
size={borderThickness+crosshairExtension.x,borderThickness};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
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};
|
size={borderThickness,crosshairExtension.y};
|
||||||
game->view.FillRectDecal(pos,size,RED);
|
game->view.FillRectDecal(pos,size,RED);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
class State_OverworldMap:public GameState{
|
class State_OverworldMap:public GameState{
|
||||||
friend class Crawler;
|
friend class Crawler;
|
||||||
ConnectionPoint*currentConnectionPoint;
|
ConnectionPoint*currentConnectionPoint;
|
||||||
float currentTime;
|
float currentTime=0;
|
||||||
vf2d playerTargetPos;
|
vf2d playerTargetPos;
|
||||||
const float playerMoveSpd=48.0;
|
const float playerMoveSpd=48.0;
|
||||||
public:
|
public:
|
||||||
@@ -13,7 +13,7 @@ public:
|
|||||||
static std::vector<ConnectionPoint>connections;
|
static std::vector<ConnectionPoint>connections;
|
||||||
static ConnectionPoint&GetCurrentConnectionPoint();
|
static ConnectionPoint&GetCurrentConnectionPoint();
|
||||||
void SetStageMarker(std::string connectionName);
|
void SetStageMarker(std::string connectionName);
|
||||||
ConnectionPoint&ConnectionPointFromIndex(int ind);
|
static ConnectionPoint&ConnectionPointFromIndex(int ind);
|
||||||
virtual void OnStateChange(GameState*prevState)override;
|
virtual void OnStateChange(GameState*prevState)override;
|
||||||
virtual void OnUserUpdate(Crawler*game)override;
|
virtual void OnUserUpdate(Crawler*game)override;
|
||||||
virtual void Draw(Crawler*game)override;
|
virtual void Draw(Crawler*game)override;
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 1
|
#define VERSION_PATCH 1
|
||||||
#define VERSION_BUILD 2718
|
#define VERSION_BUILD 2736
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
|||||||
Reference in New Issue
Block a user