Upper level and lower level rendering handled properly.

pull/28/head
sigonasr2 1 year ago
parent 440b2cb139
commit 7348426c71
  1. 40
      Crawler/Crawler.cpp
  2. 4
      Crawler/Monster.cpp
  3. 1
      Crawler/Monster.h
  4. 2
      Crawler/Version.h

@ -115,6 +115,7 @@ bool Crawler::OnUserCreate(){
}
bool Crawler::OnUserUpdate(float fElapsedTime){
fElapsedTime=std::min(1/60.f,fElapsedTime);
HandleUserInput(fElapsedTime);
UpdateEffects(fElapsedTime);
player.Update(fElapsedTime);
@ -733,7 +734,7 @@ void Crawler::RenderWorld(float fElapsedTime){
for(LayerTag&layer:MAP_DATA[currentLevel].LayerData){
if(IsBridgeLayer(layer)){
bridgeLayer=&layer;
if(!bridgeLayerFade){
if(!bridgeLayerFade&&!player.upperLevel){
int tileID=layer.tiles[y][x]-1;
if(tileID!=-1){
int playerXTruncated=int(player.GetPos().x)/24;
@ -782,23 +783,29 @@ void Crawler::RenderWorld(float fElapsedTime){
e.Draw();
}
for(Monster&m:monstersBefore){
m.Draw();
if(!m.OnUpperLevel()){
m.Draw();
}
}
vf2d playerScale=vf2d(player.GetSizeMult(),player.GetSizeMult());
vf2d playerPosition=player.GetPos();
#define RENDER_PLAYER view.DrawPartialRotatedDecal(playerPosition+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),player.GetSpinAngle(),{12,12},player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,playerScale,player.GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE);
if(player.teleportAnimationTimer>0){
playerScale.x=120*abs(pow(player.teleportAnimationTimer-0.175,3));
playerPosition=player.teleportStartPosition.lerp(player.teleportTarget,(0.35-player.teleportAnimationTimer)/0.35);
RENDER_PLAYER
} else {
#define RENDER_PLAYER \
if(player.teleportAnimationTimer>0){ \
playerScale.x=120*abs(pow(player.teleportAnimationTimer-0.175,3)); \
playerPosition=player.teleportStartPosition.lerp(player.teleportTarget,(0.35-player.teleportAnimationTimer)/0.35); \
view.DrawPartialRotatedDecal(playerPosition+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),player.GetSpinAngle(),{12,12},player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,playerScale,player.GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE); \
} else {view.DrawPartialRotatedDecal(playerPosition+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),player.GetSpinAngle(),{12,12},player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,playerScale,player.GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE);}
//define end
if(!player.upperLevel){
RENDER_PLAYER
}
if(player.GetState()==State::BLOCK){
view.DrawDecal(player.GetPos()-vf2d{12,12},GFX_BLOCK_BUBBLE.Decal());
}
for(Monster&m:monstersAfter){
m.Draw();
if(!m.OnUpperLevel()){
m.Draw();
}
}
for(Effect&e:foregroundEffects){
e.Draw();
@ -848,6 +855,19 @@ void Crawler::RenderWorld(float fElapsedTime){
}
}
#pragma endregion
for(Monster&m:monstersBefore){
if(m.OnUpperLevel()){
m.Draw();
}
}
if(player.upperLevel){
RENDER_PLAYER
}
for(Monster&m:monstersAfter){
if(m.OnUpperLevel()){
m.Draw();
}
}
#pragma region Upper Foreground Rendering
for(TileGroup&group:upperForegroundTileGroups){
if(geom2d::overlaps(group.GetRange(),player.pos)){
@ -1087,7 +1107,7 @@ bool Crawler::IsBridgeLayer(LayerTag&layer){
geom2d::rect<int>Crawler::GetTileCollision(MapName map,vf2d pos,bool upperLevel){
if(pos.x<0||pos.y<0||pos.x>=WORLD_SIZE.x*24||pos.y>=WORLD_SIZE.y*24)return NO_COLLISION;
for(LayerTag&layer:MAP_DATA[map].LayerData){
auto HasNoClass=[&](){return layer.tag.data.find("class")==layer.tag.data.end();};
auto HasNoClass=[&](){return layer.tag.data.find("class")==layer.tag.data.end()&&!upperLevel;};
auto BridgeCollisionIsActivated=[&](){return (IsBridgeLayer(layer)&&upperLevel);};
if(HasNoClass()||BridgeCollisionIsActivated()){
int tileID=layer.tiles[int(pos.y)/24][int(pos.x)/24]-1;

@ -327,6 +327,10 @@ void MonsterSpawner::SetTriggered(bool trigger,bool spawnMonsters){
}
}
bool Monster::OnUpperLevel(){
return upperLevel;
}
void Monster::AddBuff(BuffType type,float duration,float intensity){
buffList.push_back(Buff{type,duration,intensity});
}

@ -110,6 +110,7 @@ protected:
bool SetY(float y);
void PerformJumpAnimation();
void PerformShootAnimation();
bool OnUpperLevel();
void AddBuff(BuffType type,float duration,float intensity);
std::vector<Buff>GetBuffs(BuffType buff);

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 498
#define VERSION_BUILD 503
#define stringify(a) stringify_(a)
#define stringify_(a) #a

Loading…
Cancel
Save