diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj b/Adventures in Lestoria/Adventures in Lestoria.vcxproj index 059b048f..936e6179 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj @@ -537,6 +537,10 @@ + + + + @@ -726,6 +730,10 @@ + + + + diff --git a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters index 679d796c..050e266e 100644 --- a/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters +++ b/Adventures in Lestoria/Adventures in Lestoria.vcxproj.filters @@ -687,6 +687,12 @@ Source Files\Effects + + Source Files\Effects + + + Header Files + diff --git a/Adventures in Lestoria/BlackHole.h b/Adventures in Lestoria/BlackHole.h index edf487df..c2d5e3c8 100644 --- a/Adventures in Lestoria/BlackHole.h +++ b/Adventures in Lestoria/BlackHole.h @@ -38,17 +38,18 @@ All rights reserved. #pragma once #include "AdventuresInLestoria.h" #include "util.h" +#include "Effect.h" INCLUDE_MONSTER_LIST struct BlackHole:FadeInOutEffect{ - inline BlackHole(OscillatorVf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,OscillatorFloat size,vf2d spd,OscillatorPixel col,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function&particleGenerator={}) - :FadeInOutEffect(pos,img,lifetime,cycleSpd,onUpperLevel,size,spd,col,rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} - + inline BlackHole(Oscillatorpos,const std::string&img,float lifetime,bool onUpperLevel,Oscillatorsize,vf2d spd,Oscillatorcol,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function&particleGenerator={}) + :FadeInOutEffect(pos,img,lifetime,onUpperLevel,size,spd,col,rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} + inline bool Update(float fElapsedTime){ for(std::shared_ptr&m:MONSTER_LIST){ float distToMonster{util::distance(pos,m->GetPos())}; - if(distToMonster<="Black Hole"_ENC["PULL IN RADIUS"]/100.f*24){ + if(!m->IsSolid()&&m->OnUpperLevel()==OnUpperLevel()&&m->GetZ()<1.f&&distToMonster<="Black Hole"_ENC["PULL IN RADIUS"]/100.f*24){ float pullInForce{util::map_range(distToMonster,0,"Black Hole"_ENC["PULL IN RADIUS"]/100.f*24,"Black Hole"_ENC["PULL IN FORCE MAX"],"Black Hole"_ENC["PULL IN FORCE MIN"])}; m->AddAddedVelocity(util::pointTo(m->GetPos(),pos)*pullInForce); } diff --git a/Adventures in Lestoria/BulletTypes.h b/Adventures in Lestoria/BulletTypes.h index 614fb0c9..3c7ffe71 100644 --- a/Adventures in Lestoria/BulletTypes.h +++ b/Adventures in Lestoria/BulletTypes.h @@ -39,6 +39,7 @@ All rights reserved. #include "Bullet.h" #include "Direction.h" #include "Effect.h" +#include "TrailEffect.h" struct EnergyBolt:public Bullet{ float lastParticleSpawn=0; @@ -56,6 +57,8 @@ struct FireBolt:public Bullet{ BulletDestroyState PlayerHit(Player*player)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _PlayerHit()!! BulletDestroyState MonsterHit(Monster&monster,const uint8_t markStacksBeforeHit)override;//DO NOT CALL THIS DIRECTLY! INSTEAD USE _MonsterHit()!! void ModifyOutgoingDamageData(HurtDamageInfo&data); +private: + std::optional>flameTrail; }; struct LightningBolt:public Bullet{ diff --git a/Adventures in Lestoria/DeadlyDash.cpp b/Adventures in Lestoria/DeadlyDash.cpp index 9a489800..27223321 100644 --- a/Adventures in Lestoria/DeadlyDash.cpp +++ b/Adventures in Lestoria/DeadlyDash.cpp @@ -79,7 +79,7 @@ void DeadlyDash::Draw(const Pixel blendCol)const{ for(int i:std::ranges::iota_view(0,afterImageCount)){ const float fadeTimeBegins{(i+1)*afterImagesLingeringTime}; uint8_t alpha{255U}; - if(GetAliveTime()>fadeTimeBegins)alpha=std::max(0.f,util::lerp(255,0,(GetAliveTime()-fadeTimeBegins)/afterImagesLingeringTime)); + if(GetAliveTime()>fadeTimeBegins)alpha=std::max(0.f,float(util::lerp(255,0,(GetAliveTime()-fadeTimeBegins)/afterImagesLingeringTime))); const Animate2D::FrameSequence&animation{ANIMATION_DATA[this->animation]}; const float animationFrameTimer{i*animation.m_fFrameDuration}; diff --git a/Adventures in Lestoria/Effect.h b/Adventures in Lestoria/Effect.h index d27f848a..7448a9de 100644 --- a/Adventures in Lestoria/Effect.h +++ b/Adventures in Lestoria/Effect.h @@ -40,12 +40,10 @@ All rights reserved. #include "IBullet.h" #include #include +#include "Oscillator.h" class Monster; class Player; using HitList=std::unordered_set>; -using OscillatorVf2d=std::pair; -using OscillatorPixel=std::pair; -using OscillatorFloat=std::pair; enum class EffectType{ NONE, @@ -175,15 +173,14 @@ struct FadeInOutEffect:Effect{ //cycleSpd is how long it takes to get from fully opaque to fully transparent, and back to fully opaque FadeInOutEffect(vf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,float size,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function&particleGenerator={}); //A version with oscillators for position and colors, for extra animation effects! - FadeInOutEffect(OscillatorVf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,OscillatorFloat size,vf2d spd,OscillatorPixel col,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function&particleGenerator={}); + FadeInOutEffect(Oscillatorpos,const std::string&img,float lifetime,bool onUpperLevel,Oscillatorsize,vf2d spd,Oscillatorcol,float rotation,float rotationSpd,bool additiveBlending=false,float particleSpawnFreq=0.f,const std::function&particleGenerator={}); virtual bool Update(float fElapsedTime)override; virtual void Draw()const override; std::functionparticleGenerator; const float particleSpawnFreq; - const float cycleSpd; - const OscillatorVf2d posOscillator; - const OscillatorFloat sizeOscillator; - const OscillatorPixel colOscillator; + OscillatorposOscillator; + OscillatorsizeOscillator; + OscillatorcolOscillator; float particleSpawnTimer{}; const float originalParticleSpawnTimer{}; }; diff --git a/Adventures in Lestoria/EnergyBolt.cpp b/Adventures in Lestoria/EnergyBolt.cpp index 6647a910..74a2ec08 100644 --- a/Adventures in Lestoria/EnergyBolt.cpp +++ b/Adventures in Lestoria/EnergyBolt.cpp @@ -69,7 +69,7 @@ BulletDestroyState EnergyBolt::MonsterHit(Monster&monster,const uint8_t markStac { if(!game->GetPlayer()->HasEnchant("Piercing Bolt"))fadeOutTime="Wizard.Auto Attack.BulletHitFadeoutTime"_F; game->AddEffect(std::make_unique(monster.GetPos(),0,"splash_effect.png",upperLevel,monster.GetSizeMult(),"Wizard.Auto Attack.SplashEffectFadeoutTime"_F)); - if(hitList.size()==1)damage=ceil(float(damage)/2); + if(hitList.size()==1)damage=ceil(damage*"Piercing Bolt"_ENC["MULTI TARGET DAMAGE"]/100.f); return BulletDestroyState::KEEP_ALIVE; } diff --git a/Adventures in Lestoria/FadeInOutEffect.cpp b/Adventures in Lestoria/FadeInOutEffect.cpp index b903454a..771d85d3 100644 --- a/Adventures in Lestoria/FadeInOutEffect.cpp +++ b/Adventures in Lestoria/FadeInOutEffect.cpp @@ -44,9 +44,9 @@ All rights reserved. INCLUDE_game FadeInOutEffect::FadeInOutEffect(vf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,float size,vf2d spd,Pixel col,float rotation,float rotationSpd,bool additiveBlending,float particleSpawnFreq,const std::function&particleGenerator) - :FadeInOutEffect({pos,pos},img,lifetime,cycleSpd,onUpperLevel,{size,size},spd,{col,{col.r,col.g,col.b,0}},rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} -FadeInOutEffect::FadeInOutEffect(OscillatorVf2d pos,const std::string&img,float lifetime,float cycleSpd,bool onUpperLevel,OscillatorFloat size,vf2d spd,OscillatorPixel col,float rotation,float rotationSpd,bool additiveBlending,float particleSpawnFreq,const std::function&particleGenerator) - :particleSpawnFreq(particleSpawnFreq),particleGenerator(particleGenerator),cycleSpd(cycleSpd),particleSpawnTimer(particleSpawnFreq),originalParticleSpawnTimer(particleSpawnTimer),posOscillator(pos),colOscillator(col),sizeOscillator(size),Effect(pos.first,lifetime,img,onUpperLevel,size.first,0.25f,spd,col.first,rotation,rotationSpd,additiveBlending){} + :FadeInOutEffect({pos,pos,cycleSpd},img,lifetime,onUpperLevel,{{size,size},{size,size},cycleSpd},spd,{col,{col.r,col.g,col.b,0},cycleSpd},rotation,rotationSpd,additiveBlending,particleSpawnFreq,particleGenerator){} +FadeInOutEffect::FadeInOutEffect(Oscillatorpos,const std::string&img,float lifetime,bool onUpperLevel,Oscillatorsize,vf2d spd,Oscillatorcol,float rotation,float rotationSpd,bool additiveBlending,float particleSpawnFreq,const std::function&particleGenerator) + :particleSpawnFreq(particleSpawnFreq),particleGenerator(particleGenerator),particleSpawnTimer(particleSpawnFreq),originalParticleSpawnTimer(particleSpawnTimer),posOscillator(pos),colOscillator(col),sizeOscillator(size),Effect(pos.first,lifetime,img,onUpperLevel,size.first,0.25f,spd,col.first,rotation,rotationSpd,additiveBlending){} bool FadeInOutEffect::Update(float fElapsedTime){ if(particleGenerator){ particleSpawnTimer-=fElapsedTime; @@ -55,11 +55,9 @@ bool FadeInOutEffect::Update(float fElapsedTime){ game->AddEffect(std::make_unique(particleGenerator(*this))); } } - float t{float(abs(sin(PI*game->GetRunTime()*cycleSpd)))}; - pos=posOscillator.first.lerp(posOscillator.second,t); - size={util::lerp(sizeOscillator.first,sizeOscillator.second,t),util::lerp(sizeOscillator.first,sizeOscillator.second,t)}; - col=PixelLerp(colOscillator.first,colOscillator.second,t); - col.a=util::lerp(colOscillator.first.a,colOscillator.second.a,t); + pos=posOscillator.Update(fElapsedTime); + size=sizeOscillator.Update(fElapsedTime); + col=colOscillator.Update(fElapsedTime); return Effect::Update(fElapsedTime); } void FadeInOutEffect::Draw()const{ diff --git a/Adventures in Lestoria/Minimap.cpp b/Adventures in Lestoria/Minimap.cpp index 117ee620..6199adf7 100644 --- a/Adventures in Lestoria/Minimap.cpp +++ b/Adventures in Lestoria/Minimap.cpp @@ -218,7 +218,7 @@ void Minimap::UpdateChunk(const MapName map,const vi2d chunkPos,const InitialLoa const vi2d chunkOffset={"Minimap.Chunk Size"_I/2,"Minimap.Chunk Size"_I/2}; const float distance=geom2d::line(centerChunkPos+chunkOffset,vf2d{float(x),float(y)}).length(); - const int alpha=std::clamp(util::lerp(255,0,(distance-"Minimap.Chunk Size"_I)/"Minimap.Chunk Size"_I),0.f,255.f); + const int alpha=std::clamp(float(util::lerp(255,0,(distance-"Minimap.Chunk Size"_I)/"Minimap.Chunk Size"_I)),0.f,255.f); if(cover.Sprite()->GetPixel(x,y).a>alpha)continue; //The distance was uncovered by another closer chunk, don't need to reveal it here. diff --git a/Adventures in Lestoria/Oscillator.h b/Adventures in Lestoria/Oscillator.h new file mode 100644 index 00000000..7f5d580e --- /dev/null +++ b/Adventures in Lestoria/Oscillator.h @@ -0,0 +1,64 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#pragma once + +#include "util.h" + +template +class Oscillator{ +public: + Oscillator() + :Oscillator({},{},0.f){} + Oscillator(T val1,T val2,float cycleSpd) + :val1(val1),val2(val2),first(this->val1),second(this->val2),cycleSpd(cycleSpd),currentVal(val1){} + const T&Update(const float fElapsedTime){ + currentVal=util::lerp(val1,val2,sin(PI*timer*cycleSpd)/2+0.5f); + timer+=fElapsedTime; + return get(); + } + const T&get(){ + return currentVal; + }; + const T&first; + const T&second; +private: + T val1,val2; + T currentVal; + float cycleSpd; + double timer{}; +}; \ No newline at end of file diff --git a/Adventures in Lestoria/TrailEffect.h b/Adventures in Lestoria/TrailEffect.h new file mode 100644 index 00000000..7b19df11 --- /dev/null +++ b/Adventures in Lestoria/TrailEffect.h @@ -0,0 +1,57 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions or derivations of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +2. Redistributions or derivative works in binary form must reproduce the above +copyright notice. This list of conditions and the following disclaimer must be +reproduced in the documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors may +be used to endorse or promote products derived from this software without specific +prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +Portions of this software are copyright © 2024 The FreeType +Project (www.freetype.org). Please see LICENSE_FT.txt for more information. +All rights reserved. +*/ +#pragma endregion +#pragma once + +#include "Effect.h" + +class TrailEffect:Effect{ + inline TrailEffect(vf2d startPos,float lifetime,const std::string&imgFile,bool upperLevel,float fadeout,vf2d scale,float imgXOffsetSpd,Oscillatorcol,EffectType type=EffectType::NONE,bool additiveBlending=false) + :Effect(pos,lifetime,imgFile,upperLevel,scale,fadeout,{},col.first,0.f,0.f,additiveBlending){} + inline void SetEndPos(const vf2d pos){ + this->endPos=pos; + } + inline bool Update(float fElapsedTime){ + col.Update(fElapsedTime); + } + inline void Draw()const{ + + } +private: + Oscillatorcol; + vf2d endPos{}; +}; \ No newline at end of file diff --git a/Adventures in Lestoria/Version.h b/Adventures in Lestoria/Version.h index a41308ae..2ca71a36 100644 --- a/Adventures in Lestoria/Version.h +++ b/Adventures in Lestoria/Version.h @@ -39,7 +39,7 @@ All rights reserved. #define VERSION_MAJOR 1 #define VERSION_MINOR 2 #define VERSION_PATCH 5 -#define VERSION_BUILD 11250 +#define VERSION_BUILD 11271 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Adventures in Lestoria/Wizard.cpp b/Adventures in Lestoria/Wizard.cpp index 7ba4e2cf..ba34c539 100644 --- a/Adventures in Lestoria/Wizard.cpp +++ b/Adventures in Lestoria/Wizard.cpp @@ -156,14 +156,14 @@ void Wizard::InitializeClassAbilities(){ if(game->TestingModeEnabled()||dist>0&&p->CanPathfindTo(p->GetPos(),teleportPoint,float("Wizard.Right Click Ability.TilesMax"_I)) &&(NoTileCollisionExistsHere()||NoPlayerCollisionWithTile())){ if(p->HasEnchant("Blink Portal")){ - Effect&eff{game->AddEffect(std::make_unique(OscillatorVf2d{p->GetPos(),p->GetPos()+vf2d{0,-6.f}},"portal.png","Blink Portal"_ENC["REACTIVATION TIME"],0.5f,p->OnUpperLevel(),OscillatorFloat{0.9f,1.1f},vf2d{},OscillatorPixel{WHITE,0x50196f},0.f,0.f),true)}; + Effect&eff{game->AddEffect(std::make_unique(Oscillator{p->GetPos(),p->GetPos()+vf2d{0,-6.f},0.5f},"portal.png","Blink Portal"_ENC["REACTIVATION TIME"],p->OnUpperLevel(),Oscillator{{0.9f,0.9f},{1.1f,1.1f},0.5f},vf2d{},Oscillator{WHITE,Pixel(0x50196f),0.5f},0.f,0.f),true)}; eff.SetType(EffectType::BLINK_PORTAL); } TeleportTo(teleportPoint); p->lastPathfindingCooldown=0.1f; if(p->HasEnchant("Black Hole")){ - Effect&blackHoleEff{game->AddEffect(std::make_unique(OscillatorVf2d{p->GetPos(),p->GetPos()+vf2d{0,-6.f}},"blackhole.png","Black Hole"_ENC["BLACK HOLE DURATION"],0.75f,p->OnUpperLevel(),OscillatorFloat{3.4f,3.7f},vf2d{},OscillatorPixel{WHITE,WHITE},util::random(2*PI),PI/3,false,0.03f,[](const Effect&self){ + Effect&blackHoleEff{game->AddEffect(std::make_unique(Oscillator{p->GetPos(),p->GetPos()+vf2d{0,-6.f},0.75f},"blackhole.png","Black Hole"_ENC["BLACK HOLE DURATION"],p->OnUpperLevel(),Oscillator{{3.4f,3.4f},{3.7f,3.7f},0.75f},vf2d{},Oscillator{WHITE,WHITE,0.75f},util::random(2*PI),PI/3,false,0.03f,[](const Effect&self){ vf2d particlePos{self.pos+vf2d{"Black Hole"_ENC["PULL IN RADIUS"]/100.f*24,util::random(2*PI)}.cart()}; return Effect{particlePos,util::random_range(0.3f,0.5f),"pixel.png",self.OnUpperLevel(),util::random(2.f),0.1f,util::pointTo(particlePos,self.pos)*util::random_range(700,1000),PixelLerp(BLACK,Pixel(0x9859de),util::random(1.f)),0.f,0.f,false}; }),true)}; diff --git a/Adventures in Lestoria/assets/FlamesTexture.png b/Adventures in Lestoria/assets/FlamesTexture.png new file mode 100644 index 00000000..31995652 Binary files /dev/null and b/Adventures in Lestoria/assets/FlamesTexture.png differ diff --git a/Adventures in Lestoria/assets/config/gfx/gfx.txt b/Adventures in Lestoria/assets/config/gfx/gfx.txt index b2d1fc77..6cf02505 100644 --- a/Adventures in Lestoria/assets/config/gfx/gfx.txt +++ b/Adventures in Lestoria/assets/config/gfx/gfx.txt @@ -127,6 +127,7 @@ Images GFX_SpecialTargetMark = special_target.png GFX_BlackHole = blackhole.png GFX_Portal = portal.png + GFX_Flames = FlamesTexture.png GFX_Thief_Sheet = nico-thief.png GFX_Trapper_Sheet = nico-trapper.png diff --git a/Adventures in Lestoria/util.cpp b/Adventures in Lestoria/util.cpp index 5d6b2cf1..2400b4b1 100644 --- a/Adventures in Lestoria/util.cpp +++ b/Adventures in Lestoria/util.cpp @@ -72,10 +72,6 @@ float util::radToDeg(float rad){ return rad*57.2957795130823208767f; } -float util::lerp(float n1,float n2,double t){ - return float(n1*(1-t)+n2*t); -} - std::string util::timerStr(float time){ int seconds=int(time); int hours=seconds/3600; diff --git a/Adventures in Lestoria/util.h b/Adventures in Lestoria/util.h index ef4038b3..b8a29686 100644 --- a/Adventures in Lestoria/util.h +++ b/Adventures in Lestoria/util.h @@ -54,7 +54,27 @@ namespace olc::util{ float angleTo(vf2d posFrom,vf2d posTo); float degToRad(float deg); float radToDeg(float rad); - float lerp(float n1,float n2,double t); + + #pragma region Lerp templates + specializations + template + inline auto lerp(const T val1,const U val2,const float t){ + return decltype(val1+val2)(val1*(1-t)+val2*t); + } + + template<> + inline auto lerp(const vf2d val1,const vf2d val2,const float t){ + return val1.lerp(val2,t); + } + + template<> + //NOTE: Also interpolates the alpha!!! + inline auto lerp(const Pixel val1,const Pixel val2,const float t){ + Pixel col{PixelLerp(val1,val2,t)}; + col.a=lerp(val1.a,val2.a,t); + return col; + } + #pragma endregion + std::string timerStr(float time); std::string WrapText(PixelGameEngine*pge,std::string str,int width,bool proportional,vd2d scale); std::u32string WrapText(PixelGameEngine*pge,std::u32string str,int width,Font&font,vd2d scale); @@ -95,4 +115,4 @@ constexpr auto circ_add( } //Converts unit distances to pixels. (Every 100 units = 24 pixels) -long double operator""_Pixels(long double unitDist); +long double operator""_Pixels(long double unitDist); \ No newline at end of file diff --git a/x64/Release/Adventures in Lestoria.exe b/x64/Release/Adventures in Lestoria.exe index ce5d6193..59306d32 100644 Binary files a/x64/Release/Adventures in Lestoria.exe and b/x64/Release/Adventures in Lestoria.exe differ