diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 87f3eaa4..5fc8a4a7 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -25,7 +25,7 @@ const vi2d WINDOW_SIZE={24*15,24*10}; std::mapANIMATION_DATA; std::vectorMONSTER_LIST; std::vectorSPAWNER_LIST; -std::vectorDAMAGENUMBER_LIST; +std::vector>DAMAGENUMBER_LIST; std::vector>BULLET_LIST; Crawler*game; @@ -699,21 +699,26 @@ void Crawler::RenderWorld(float fElapsedTime){ } } #pragma endregion - for(std::vector::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ - DamageNumber&dn=*it; - dn.lifeTime+=fElapsedTime; - if(dn.lifeTime>1){ - it=DAMAGENUMBER_LIST.erase(it); - if(it==DAMAGENUMBER_LIST.end()){ - break; - } - } else { - if(dn.lifeTime>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ + DamageNumber*dn=(*it).get(); + if(dn->pauseTime>0){ + dn->pauseTime-=fElapsedTime; + } else{ + dn->lifeTime+=fElapsedTime; + if(dn->lifeTime>1){ + it=DAMAGENUMBER_LIST.erase(it); + if(it==DAMAGENUMBER_LIST.end()){ + break; + } + } else { + if(dn->lifeTimepos.y-=20*fElapsedTime; + } + } - std::string text=std::to_string(dn.damage); - view.DrawStringPropDecal(dn.pos-GetTextSizeProp(text)/2,text,DARK_RED); } + std::string text=std::to_string(dn->damage); + view.DrawStringPropDecal(dn->pos-GetTextSizeProp(text)/2,text,DARK_RED); } } diff --git a/Crawler/DEFINES.h b/Crawler/DEFINES.h index 1e5d5730..2423083f 100644 --- a/Crawler/DEFINES.h +++ b/Crawler/DEFINES.h @@ -2,7 +2,7 @@ #define INCLUDE_ANIMATION_DATA extern std::mapANIMATION_DATA; #define INCLUDE_MONSTER_LIST extern std::vectorMONSTER_LIST; #define INCLUDE_SPAWNER_LIST extern std::vectorSPAWNER_LIST; -#define INCLUDE_DAMAGENUMBER_LIST extern std::vectorDAMAGENUMBER_LIST; +#define INCLUDE_DAMAGENUMBER_LIST extern std::vector>DAMAGENUMBER_LIST; #define INCLUDE_game extern Crawler*game; #define INCLUDE_MONSTER_DATA extern std::mapMONSTER_DATA; #define INCLUDE_BULLET_LIST extern std::vector>BULLET_LIST; diff --git a/Crawler/DamageNumber.h b/Crawler/DamageNumber.h index f4088447..22d58619 100644 --- a/Crawler/DamageNumber.h +++ b/Crawler/DamageNumber.h @@ -5,6 +5,7 @@ struct DamageNumber{ vf2d pos; int damage; float lifeTime=0; + float pauseTime=0; const static float MOVE_UP_TIME; DamageNumber(); DamageNumber(vf2d pos,int damage); diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index a14cc71f..4933a5a5 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -98,6 +98,7 @@ bool Monster::SetY(float y){ return false; } bool Monster::Update(float fElapsedTime){ + lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); if(IsAlive()){ for(std::vector::iterator it=buffList.begin();it!=buffList.end();++it){ Buff&b=*it; @@ -334,7 +335,15 @@ bool Monster::Hurt(int damage,bool onUpperLevel){ mod_dmg-=damage*b.intensity; } hp=std::max(0,hp-int(mod_dmg)); - DAMAGENUMBER_LIST.push_back(DamageNumber(pos,int(mod_dmg))); + if(lastHitTimer>0){ + damageNumberPtr.get()->damage+=int(mod_dmg); + damageNumberPtr.get()->pauseTime=0.4; + } else { + DAMAGENUMBER_LIST.push_back(std::make_shared(pos,int(mod_dmg))); + std::shared_ptrnumb=*(DAMAGENUMBER_LIST.end()-1); + damageNumberPtr=numb; + } + lastHitTimer=0.05; if(hp<=0){ animation.ChangeState(internal_animState,GetDeathAnimationName()); } diff --git a/Crawler/Monster.h b/Crawler/Monster.h index 043a0e91..b5419b41 100644 --- a/Crawler/Monster.h +++ b/Crawler/Monster.h @@ -4,6 +4,7 @@ #include "State.h" #include "Buff.h" #include "olcUTIL_Animate2D.h" +#include "DamageNumber.h" struct Player; @@ -85,6 +86,8 @@ struct Monster{ vf2d pathTarget={}; std::vectorpath; int pathIndex=0; + float lastHitTimer=0; + std::shared_ptrdamageNumberPtr; protected: public: Monster()=delete; diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index c5831aa5..7889d580 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -162,6 +162,7 @@ void Player::Update(float fElapsedTime){ iframe_time=std::max(0.f,iframe_time-fElapsedTime); notEnoughManaDisplay.second=std::max(0.f,notEnoughManaDisplay.second-fElapsedTime); notificationDisplay.second=std::max(0.f,notificationDisplay.second-fElapsedTime); + lastHitTimer=std::max(0.f,lastHitTimer-fElapsedTime); manaTickTimer-=fElapsedTime; if(castInfo.castTimer>0){ castInfo.castTimer-=fElapsedTime; @@ -471,7 +472,15 @@ bool Player::Hurt(int damage,bool onUpperLevel){ mod_dmg-=damage*b.intensity; } hp=std::max(0,hp-int(mod_dmg)); - DAMAGENUMBER_LIST.push_back(DamageNumber(pos,int(mod_dmg))); + if(lastHitTimer>0){ + damageNumberPtr.get()->damage+=int(mod_dmg); + damageNumberPtr.get()->pauseTime=0.4; + } else { + DAMAGENUMBER_LIST.push_back(std::make_shared(pos,int(mod_dmg))); + std::shared_ptrnumb=*(DAMAGENUMBER_LIST.end()-1); + damageNumberPtr=numb; + } + lastHitTimer=0.05; return true; } diff --git a/Crawler/Player.h b/Crawler/Player.h index 3b5b8b54..b468ccd5 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -7,6 +7,7 @@ #include "Class.h" #include "Buff.h" #include "Pathfinding.h" +#include "DamageNumber.h" struct CastInfo{ std::string name; @@ -48,6 +49,8 @@ struct Player{ std::vectorbuffList; CastInfo castInfo={"",0}; vf2d movementVelocity={};//This tells us if the player is moving (mostly controlled by user input) since their velocity is not used for regular movement. + float lastHitTimer=0; //When this is greater than zero, if we get hit again it adds to our displayed combo number. + std::shared_ptrdamageNumberPtr; protected: const float ATTACK_COOLDOWN=0.35f; const float MAGIC_ATTACK_COOLDOWN=0.85f; diff --git a/Crawler/Version.h b/Crawler/Version.h index d7b32914..804c08b9 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -2,7 +2,7 @@ #define VERSION_MAJOR 0 #define VERSION_MINOR 2 #define VERSION_PATCH 0 -#define VERSION_BUILD 847 +#define VERSION_BUILD 854 #define stringify(a) stringify_(a) #define stringify_(a) #a diff --git a/Crawler/assets/Campaigns/1_1.tmx b/Crawler/assets/Campaigns/1_1.tmx index a424ed3b..c4da2c9b 100644 --- a/Crawler/assets/Campaigns/1_1.tmx +++ b/Crawler/assets/Campaigns/1_1.tmx @@ -1,5 +1,5 @@ - +