Transition fade added for foreground items.
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
c7f09d9513
commit
5a0e4d0d01
@ -14,6 +14,7 @@ struct ClassData{
|
||||
static void InitializeClassData();
|
||||
ClassData(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
||||
AnimationState walk_n,AnimationState walk_e,AnimationState walk_s,AnimationState walk_w,AnimationState idle_n,AnimationState idle_e,AnimationState idle_s,AnimationState idle_w);
|
||||
virtual ~ClassData()=default;
|
||||
virtual void Update(float fElapsedTime)=0;
|
||||
virtual bool AutoAttack()=0;
|
||||
virtual bool Ability1()=0;
|
||||
|
@ -851,14 +851,16 @@ void Crawler::RenderWorld(float fElapsedTime){
|
||||
}
|
||||
#pragma region Foreground Rendering
|
||||
for(TileGroup&group:foregroundTileGroups){
|
||||
if(geom2d::overlaps(group.GetRange(),player.pos)){
|
||||
if(view.IsRectVisible(group.GetRange().pos,group.GetRange().size)){
|
||||
if(geom2d::overlaps(group.GetFadeRange(),player.pos)){
|
||||
group.playerBehind=true;
|
||||
group.fadeFactor=std::min(group.fadeFactor+fElapsedTime,TileGroup::FADE_TIME);
|
||||
} else {
|
||||
group.playerBehind=false;
|
||||
group.fadeFactor=std::max(group.fadeFactor-fElapsedTime,0.f);
|
||||
}
|
||||
if(view.IsRectVisible(group.GetRange().pos,group.GetRange().size)){
|
||||
for(TileRenderData&tile:group.GetTiles()){
|
||||
view.DrawPartialDecal(tile.pos,{24,24},tile.tileset,tile.tileSheetPos,{24,24},{255,255,255,uint8_t(group.playerBehind?128:255)});
|
||||
view.DrawPartialDecal(tile.pos,{24,24},tile.tileset,tile.tileSheetPos,{24,24},{255,255,255,uint8_t(255-group.fadeFactor/TileGroup::FADE_TIME*TileGroup::FADE_AMT)});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "Map.h"
|
||||
|
||||
float TileGroup::FADE_TIME=0.3;
|
||||
uint8_t TileGroup::FADE_AMT=160;
|
||||
|
||||
void TileGroup::InsertTile(TileRenderData tile){
|
||||
if(tiles.size()==0){
|
||||
range={tile.pos,{24,24}};
|
||||
@ -29,6 +32,10 @@ geom2d::rect<int>TileGroup::GetRange(){
|
||||
return range;
|
||||
}
|
||||
|
||||
geom2d::rect<int>TileGroup::GetFadeRange(){
|
||||
return {range.pos+vi2d{-24,-24},range.size+vi2d{48,48}};
|
||||
}
|
||||
|
||||
std::vector<TileRenderData>&TileGroup::GetTiles(){
|
||||
return tiles;
|
||||
}
|
@ -33,8 +33,14 @@ private:
|
||||
std::vector<TileRenderData>tiles;
|
||||
int minX=0,minY=0,maxX=0,maxY=0;
|
||||
public:
|
||||
static float FADE_TIME;
|
||||
//0-255. 255 indicates fully invisible.
|
||||
static uint8_t FADE_AMT;
|
||||
geom2d::rect<int>GetRange();
|
||||
//The fade range is the bounds in which this tile group will be considered "in range" of a player, one tile in each direction further than its actual range.
|
||||
geom2d::rect<int>GetFadeRange();
|
||||
std::vector<TileRenderData>&GetTiles();
|
||||
void InsertTile(TileRenderData tile);
|
||||
bool playerBehind=false;
|
||||
float fadeFactor=0.f;
|
||||
};
|
@ -178,10 +178,10 @@ namespace olc::utils::geom2d
|
||||
// Get a line from an indexed side, starting top, going clockwise
|
||||
inline line<T> side(const size_t i) const
|
||||
{
|
||||
if (i & 0b11 == 0) return top();
|
||||
if (i & 0b11 == 1) return right();
|
||||
if (i & 0b11 == 2) return bottom();
|
||||
if (i & 0b11 == 3) return left();
|
||||
if (i & (0b11 == 0)) return top();
|
||||
if (i & (0b11 == 1)) return right();
|
||||
if (i & (0b11 == 2)) return bottom();
|
||||
if (i & (0b11 == 3)) return left();
|
||||
}
|
||||
|
||||
// Get area of rectangle
|
||||
|
Loading…
x
Reference in New Issue
Block a user