diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index 855d0346..47dcedd9 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -1365,42 +1365,52 @@ void AiL::RenderWorld(float fElapsedTime){ } } } + + #define NumberScalesWithDamage true + #define NormalNumber false + + auto DrawDamageNumber=[&](const bool ScaleWithNumber,std::string_view text,std::paircolorsEnemy,std::paircolorsFriendly,vf2d scaling={1.f,1.f}){ + vf2d textSize=GetTextSizeProp(text)*scaling; + if(!dn->friendly){ + vf2d additionalScaling={1.f,1.f}; + if(ScaleWithNumber)additionalScaling=dn->size; + + textSize*=additionalScaling; + vf2d drawPos=dn->pos-textSize/2.f; + + drawPos.x=std::clamp(drawPos.x,view.GetWorldTL().x,view.GetWorldBR().x-textSize.x); + drawPos.y=std::clamp(drawPos.y,view.GetWorldTL().y,view.GetWorldBR().y-textSize.y); + + view.DrawShadowStringPropDecal(drawPos,text,colorsEnemy.first,colorsEnemy.second,scaling*additionalScaling); + }else{ + vf2d drawPos=dn->pos-textSize/2.f; + drawPos.x=std::clamp(drawPos.x,view.GetWorldTL().x,view.GetWorldBR().x-textSize.x); + drawPos.y=std::clamp(drawPos.y,view.GetWorldTL().y,view.GetWorldBR().y-textSize.y); + + view.DrawShadowStringPropDecal(drawPos,text,colorsFriendly.first,colorsFriendly.second,scaling); + } + }; + switch(dn->type){ case HEALTH_LOSS:{ std::string text=std::to_string(dn->damage); - if(!dn->friendly){ - view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2.f*dn->size,text,DARK_RED,dn->size); - }else{ - view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,RED,VERY_DARK_GREY); - } + DrawDamageNumber(NumberScalesWithDamage,text,{DARK_RED,{0,0,0,0}},{RED,VERY_DARK_GREY}); }break; case HEALTH_GAIN:{ std::string text="+"+std::to_string(dn->damage); - if(!dn->friendly){ - view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_GREEN); - }else{ - view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,GREEN,VERY_DARK_GREY); - } + DrawDamageNumber(NormalNumber,text,{DARK_GREEN,{0,0,0,0}},{GREEN,VERY_DARK_GREY}); }break; case MANA_GAIN:{ std::string text="+"+std::to_string(dn->damage); - if(dn->friendly){ - view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,BLUE,VERY_DARK_GREY); - } + DrawDamageNumber(NormalNumber,text,{BLUE,VERY_DARK_GREY},{BLUE,VERY_DARK_GREY}); }break; case INTERRUPT:{ std::string text="Interrupted!"; - if(dn->friendly){ - view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,BLACK,VERY_DARK_GREY,{0.5,1}); - } + DrawDamageNumber(NormalNumber,text,{BLACK,VERY_DARK_GREY},{BLACK,VERY_DARK_GREY},{0.5f,1}); }break; case CRIT:{ std::string text=std::to_string(dn->damage); - if(!dn->friendly){ - view.DrawShadowStringPropDecal(dn->pos-GetTextSizeProp(text)/2.f*dn->size,text,YELLOW,DARK_YELLOW,dn->size); - }else{ - view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,BLACK); - } + DrawDamageNumber(NumberScalesWithDamage,text,{YELLOW,DARK_YELLOW},{BLACK,{0,0,0,0}}); }break; } } diff --git a/Adventures in Lestoria/Monster.cpp b/Adventures in Lestoria/Monster.cpp index dcd8b18c..2923e48f 100644 --- a/Adventures in Lestoria/Monster.cpp +++ b/Adventures in Lestoria/Monster.cpp @@ -690,8 +690,8 @@ void Monster::OnDeath(){ const geom2d::rectarenaBounds=game->GetZones().at("BossArena")[0].zone; geom2d::rectclampedArena{vi2d(arenaBounds.pos+"boss_spawn_ring_radius"_I),vi2d(arenaBounds.size-"boss_spawn_ring_radius"_I*2)}; - exitRing.zone.pos.x=std::clamp(exitRing.zone.pos.x,clampedArena.pos.x,clampedArena.pos.x+clampedArena.size.x); - exitRing.zone.pos.y=std::clamp(exitRing.zone.pos.y,clampedArena.pos.y,clampedArena.pos.y+clampedArena.size.y); + exitRing.zone.pos.x=std::clamp(exitRing.zone.pos.x,clampedArena.pos.x-"boss_spawn_ring_radius"_I,clampedArena.pos.x-"boss_spawn_ring_radius"_I+clampedArena.size.x); + exitRing.zone.pos.y=std::clamp(exitRing.zone.pos.y,clampedArena.pos.y-"boss_spawn_ring_radius"_I,clampedArena.pos.y-"boss_spawn_ring_radius"_I+clampedArena.size.y); game->AddZone("EndZone",exitRing); //Create a 144x144 ring around the dead boss. } diff --git a/emscripten_debug_build.sh b/emscripten_debug_build.sh new file mode 100755 index 00000000..4a0a7900 --- /dev/null +++ b/emscripten_debug_build.sh @@ -0,0 +1,4 @@ +clear +source ./emsdk/emsdk_env.sh +emcmake cmake -DCMAKE_BUILD_TYPE=Debug -D_DEBUG=1 . +cmake --build . -j 8 \ No newline at end of file