|
|
@ -1026,6 +1026,7 @@ namespace olc |
|
|
|
// Specify which Sprite should be the target of drawing functions, use nullptr
|
|
|
|
// Specify which Sprite should be the target of drawing functions, use nullptr
|
|
|
|
// to specify the primary screen
|
|
|
|
// to specify the primary screen
|
|
|
|
void SetDrawTarget(Sprite* target); |
|
|
|
void SetDrawTarget(Sprite* target); |
|
|
|
|
|
|
|
float GetRuntime() const; |
|
|
|
// Gets the current Frames Per Second
|
|
|
|
// Gets the current Frames Per Second
|
|
|
|
uint32_t GetFPS() const; |
|
|
|
uint32_t GetFPS() const; |
|
|
|
// Gets last update of elapsed time
|
|
|
|
// Gets last update of elapsed time
|
|
|
@ -1258,6 +1259,7 @@ namespace olc |
|
|
|
uint32_t nLastFPS = 0; |
|
|
|
uint32_t nLastFPS = 0; |
|
|
|
bool bPixelCohesion = false; |
|
|
|
bool bPixelCohesion = false; |
|
|
|
DecalMode nDecalMode = DecalMode::NORMAL; |
|
|
|
DecalMode nDecalMode = DecalMode::NORMAL; |
|
|
|
|
|
|
|
float fRunTime = 0.0f; |
|
|
|
DecalStructure nDecalStructure = DecalStructure::FAN; |
|
|
|
DecalStructure nDecalStructure = DecalStructure::FAN; |
|
|
|
std::function<olc::Pixel(const int x, const int y, const olc::Pixel&, const olc::Pixel&)> funcPixelMode; |
|
|
|
std::function<olc::Pixel(const int x, const int y, const olc::Pixel&, const olc::Pixel&)> funcPixelMode; |
|
|
|
std::chrono::time_point<std::chrono::system_clock> m_tp1, m_tp2; |
|
|
|
std::chrono::time_point<std::chrono::system_clock> m_tp1, m_tp2; |
|
|
@ -2119,6 +2121,9 @@ namespace olc |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float PixelGameEngine::GetRuntime() const |
|
|
|
|
|
|
|
{ return fRunTime; } |
|
|
|
|
|
|
|
|
|
|
|
uint32_t PixelGameEngine::GetFPS() const |
|
|
|
uint32_t PixelGameEngine::GetFPS() const |
|
|
|
{ return nLastFPS; } |
|
|
|
{ return nLastFPS; } |
|
|
|
|
|
|
|
|
|
|
@ -3339,30 +3344,54 @@ namespace olc |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const olc::vf2d& scale){ |
|
|
|
void PixelGameEngine::DrawStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const olc::vf2d& scale){ |
|
|
|
|
|
|
|
struct DecalData{ |
|
|
|
|
|
|
|
Decal*decal; |
|
|
|
|
|
|
|
float expireTime=0.0f; |
|
|
|
|
|
|
|
}; |
|
|
|
if(sText.length()==0)return; |
|
|
|
if(sText.length()==0)return; |
|
|
|
static Decal*temp=nullptr; |
|
|
|
static std::map<std::u32string,DecalData>garbageCollector; |
|
|
|
if(temp!=nullptr){ |
|
|
|
std::u32string key=font.GetFontName()+U"_"+sText; |
|
|
|
delete temp; |
|
|
|
if(!garbageCollector.count(key)){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
|
|
|
|
} |
|
|
|
garbageCollector[key].decal=font.RenderStringToDecal(sText,WHITE); |
|
|
|
temp=font.RenderStringToDecal(sText,col); |
|
|
|
} |
|
|
|
DrawDecal(pos,temp,scale/4,col); |
|
|
|
garbageCollector[key].expireTime=GetRuntime()+120.0f; |
|
|
|
|
|
|
|
std::erase_if(garbageCollector,[&](auto&key){ |
|
|
|
|
|
|
|
if(key.second.expireTime<GetRuntime()){ |
|
|
|
|
|
|
|
delete key.second.decal; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
DrawDecal(pos,garbageCollector[key].decal,scale/4,col); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
void PixelGameEngine::DrawShadowStringDecal(Font&font, const olc::vf2d& pos, const std::u32string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
|
|
|
|
struct DecalData{ |
|
|
|
|
|
|
|
Decal*decal; |
|
|
|
|
|
|
|
float expireTime=0.0f; |
|
|
|
|
|
|
|
}; |
|
|
|
if(sText.length()==0)return; |
|
|
|
if(sText.length()==0)return; |
|
|
|
static Decal*temp=nullptr; |
|
|
|
static std::map<std::u32string,DecalData>garbageCollector; |
|
|
|
if(temp!=nullptr){ |
|
|
|
std::u32string key=font.GetFontName()+U"_"+sText; |
|
|
|
delete temp; |
|
|
|
if(!garbageCollector.count(key)){ //If the text key already exists, don't have to recreate the decal, just update the expire time.
|
|
|
|
} |
|
|
|
garbageCollector[key].decal=font.RenderStringToDecal(sText,WHITE); |
|
|
|
temp=font.RenderStringToDecal(sText,col); |
|
|
|
} |
|
|
|
|
|
|
|
garbageCollector[key].expireTime=GetRuntime()+120.0f; |
|
|
|
|
|
|
|
std::erase_if(garbageCollector,[&](auto&key){ |
|
|
|
|
|
|
|
if(key.second.expireTime<GetRuntime()){ |
|
|
|
|
|
|
|
delete key.second.decal; |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
}); |
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
for(float y=-shadowSizeFactor;y<=shadowSizeFactor+0.1;y+=shadowSizeFactor/2){ |
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
for(float x=-shadowSizeFactor;x<=shadowSizeFactor+0.1;x+=shadowSizeFactor/2){ |
|
|
|
if(x!=0||y!=0){ |
|
|
|
if(x!=0||y!=0){ |
|
|
|
DrawDecal(pos+vf2d{x,y},temp,scale/4,shadowCol); |
|
|
|
DrawDecal(pos+vf2d{x,y},garbageCollector[key].decal,scale/4,shadowCol); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
DrawDecal(pos,temp,scale/4,col); |
|
|
|
DrawDecal(pos,garbageCollector[key].decal,scale/4,col); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void PixelGameEngine::DrawShadowStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
|
void PixelGameEngine::DrawShadowStringPropDecal(const olc::vf2d& pos, const std::string& sText, const Pixel col, const Pixel shadowCol, const olc::vf2d& scale,const float shadowSizeFactor){ |
|
|
@ -3990,6 +4019,7 @@ namespace olc |
|
|
|
// Our time per frame coefficient
|
|
|
|
// Our time per frame coefficient
|
|
|
|
float fElapsedTime = elapsedTime.count(); |
|
|
|
float fElapsedTime = elapsedTime.count(); |
|
|
|
fLastElapsed = fElapsedTime; |
|
|
|
fLastElapsed = fElapsedTime; |
|
|
|
|
|
|
|
fRunTime += fElapsedTime; |
|
|
|
|
|
|
|
|
|
|
|
if (bConsoleSuspendTime) |
|
|
|
if (bConsoleSuspendTime) |
|
|
|
fElapsedTime = 0.0f; |
|
|
|
fElapsedTime = 0.0f; |
|
|
|