Add in zoom targeting and ease-in functions for the camera system. Release Build 10094.

removeExposedPackKey
sigonasr2 5 months ago
parent 352847ab27
commit ed4a755d1c
  1. 8
      Adventures in Lestoria/AdventuresInLestoria.cpp
  2. 2
      Adventures in Lestoria/AdventuresInLestoria.h
  3. 2
      Adventures in Lestoria/Version.h
  4. 5
      Adventures in Lestoria/olcPGEX_TransformedView.h
  5. BIN
      x64/Release/Adventures in Lestoria.exe

@ -706,6 +706,10 @@ void AiL::UpdateCamera(float fElapsedTime){
worldShake=player->GetPos()+worldShakeVel; worldShake=player->GetPos()+worldShakeVel;
} }
camera.Update(fElapsedTime); camera.Update(fElapsedTime);
if(view.GetZoom().x!=targetZoom){
if(view.GetZoom().x<targetZoom)view.SetZoom(std::min(view.GetZoom().x+zoomAdjustSpeed*fElapsedTime,targetZoom),camera.GetTarget());
else view.SetZoom(std::max(view.GetZoom().x-zoomAdjustSpeed*fElapsedTime,targetZoom),camera.GetTarget());
}
view.SetWorldOffset(camera.GetViewPosition()); view.SetWorldOffset(camera.GetViewPosition());
} }
@ -2354,7 +2358,8 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
Audio::muted=true; Audio::muted=true;
Audio::UpdateBGMVolume(); Audio::UpdateBGMVolume();
#endif #endif
game->view.SetZoom(1.f,game->view.WorldToScreen(game->camera.GetViewPosition())); targetZoom=1.f;
game->view.SetZoom(1.2f,game->view.WorldToScreen(game->camera.GetViewPosition()));
worldColor=WHITE; worldColor=WHITE;
worldColorFunc=[&](vi2d pos){return game->worldColor;}; worldColorFunc=[&](vi2d pos){return game->worldColor;};
levelTime=0; levelTime=0;
@ -2371,7 +2376,6 @@ void AiL::_PrepareLevel(MapName map,MusicChange changeMusic){
Inventory::ResetLoadoutItemsUsed(); Inventory::ResetLoadoutItemsUsed();
Input::StopVibration(); Input::StopVibration();
Input::SetLightbar({255,0,255}); Input::SetLightbar({255,0,255});
GetPlayer()->hp=GetPlayer()->GetMaxHealth(); GetPlayer()->hp=GetPlayer()->GetMaxHealth();
GetPlayer()->mana=GetPlayer()->GetMaxMana(); GetPlayer()->mana=GetPlayer()->GetMaxMana();

@ -225,6 +225,8 @@ private:
std::optional<vf2d>bossIndicatorPos{}; std::optional<vf2d>bossIndicatorPos{};
bool steamAPIEnabled{true}; bool steamAPIEnabled{true};
Overlay hudOverlay{"pixel.png",BLANK}; Overlay hudOverlay{"pixel.png",BLANK};
float targetZoom{1.f};
float zoomAdjustSpeed{0.1f};
public: public:
AiL(); AiL();
bool OnUserCreate() override; bool OnUserCreate() override;

@ -39,7 +39,7 @@ All rights reserved.
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 2 #define VERSION_MINOR 2
#define VERSION_PATCH 3 #define VERSION_PATCH 3
#define VERSION_BUILD 10093 #define VERSION_BUILD 10094
#define stringify(a) stringify_(a) #define stringify(a) stringify_(a)
#define stringify_(a) #a #define stringify_(a) #a

@ -102,6 +102,7 @@ namespace olc
olc::vf2d GetWorldVisibleArea() const; olc::vf2d GetWorldVisibleArea() const;
void ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos); void ZoomAtScreenPos(const float fDeltaZoom, const olc::vi2d& vPos);
void SetZoom(const float fZoom, const olc::vf2d& vPos); void SetZoom(const float fZoom, const olc::vf2d& vPos);
const vf2d&GetZoom()const;
void StartPan(const olc::vi2d& vPos); void StartPan(const olc::vi2d& vPos);
void UpdatePan(const olc::vi2d& vPos); void UpdatePan(const olc::vi2d& vPos);
void EndPan(const olc::vi2d& vPos); void EndPan(const olc::vi2d& vPos);
@ -292,6 +293,10 @@ namespace olc
m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom; m_vWorldOffset += vOffsetBeforeZoom - vOffsetAfterZoom;
} }
const vf2d&TransformedView::GetZoom()const{
return m_vWorldScale;
}
void TransformedView::StartPan(const olc::vi2d& vPos) void TransformedView::StartPan(const olc::vi2d& vPos)
{ {
m_bPanning = true; m_bPanning = true;

Loading…
Cancel
Save