Fixed fElapsedTime bug going negative seemingly randomly. Thank std::chrono::library::that::is::way::too::annoying::to::use::and::apparently::is::not::ultra::accurate

pull/28/head
sigonasr2 1 year ago
parent 9ebe5a21a0
commit 24030733bd
  1. 10
      Crawler/Crawler.cpp
  2. 3
      Crawler/DEFINES.h
  3. 25
      Crawler/Player.cpp
  4. 10
      Crawler/Ranger.cpp
  5. 2
      Crawler/Version.h

@ -96,7 +96,7 @@ bool Crawler::OnUserCreate(){
}
bool Crawler::OnUserUpdate(float fElapsedTime){
fElapsedTime=std::min(1/60.f,fElapsedTime);
fElapsedTime=std::clamp(fElapsedTime,0.f,1/60.f);
HandleUserInput(fElapsedTime);
UpdateEffects(fElapsedTime);
player->Update(fElapsedTime);
@ -727,16 +727,16 @@ void Crawler::RenderHud(){
player->GetAbility3(),
player->GetAbility4(),
};
std::vector<Ability>activeCooldowns;
std::copy_if(cooldowns.begin(),cooldowns.end(),std::back_inserter(activeCooldowns),[](Ability a){
std::vector<Ability>activeCooldowns{};
std::copy_if(cooldowns.begin(),cooldowns.end(),std::back_inserter(activeCooldowns),[](Ability&a){
return a.cooldown>0;
});
std::sort(activeCooldowns.begin(),activeCooldowns.end(),[](Ability&a1,Ability&a2){
std::sort(activeCooldowns.begin(),activeCooldowns.end(),[&](Ability&a1,Ability&a2){
return a1.cooldown<a2.cooldown;
});
int offset=6*activeCooldowns.size();
for(Ability&a:activeCooldowns){
if(a.cooldown>0){
if(a.cooldown>0.1){
FillRectDecal(vf2d{10,ScreenHeight()-22.f}-vf2d{0,float(offset)},{64,6},BLACK);
FillRectDecal(vf2d{11,ScreenHeight()-21.f}-vf2d{0,float(offset)},{62,4},DARK_GREY);
GradientFillRectDecal(vf2d{10,ScreenHeight()-22.f}-vf2d{0,float(offset)},{(a.cooldown/a.COOLDOWN_TIME)*64,6},a.barColor1,a.barColor1,a.barColor2,a.barColor2);

@ -14,7 +14,8 @@
#define INFINITE 999999
#define SETUP_CLASS(class) \
class::class(){} \
class::class() \
:Player::Player(){} \
class::class(Player*player) \
:Player::Player(player){} \
Class class::GetClass(){return cl;} \

@ -265,11 +265,26 @@ void Player::Update(float fElapsedTime){
animation.UpdateState(internal_animState,fElapsedTime);
}
}
rightClickAbility.cooldown=std::max(0.f,rightClickAbility.cooldown-fElapsedTime);
ability.cooldown=std::max(0.f,ability.cooldown-fElapsedTime);
ability2.cooldown=std::max(0.f,ability2.cooldown-fElapsedTime);
ability3.cooldown=std::max(0.f,ability3.cooldown-fElapsedTime);
ability4.cooldown=std::max(0.f,ability4.cooldown-fElapsedTime);
rightClickAbility.cooldown-=fElapsedTime;
ability.cooldown-=fElapsedTime;
ability2.cooldown-=fElapsedTime;
ability3.cooldown-=fElapsedTime;
ability4.cooldown-=fElapsedTime;
if(rightClickAbility.cooldown<0){
rightClickAbility.cooldown=0;
}
if(ability.cooldown<0){
ability.cooldown=0;
}
if(ability2.cooldown<0){
ability2.cooldown=0;
}
if(ability3.cooldown<0){
ability3.cooldown=0;
}
if(ability4.cooldown<0){
ability4.cooldown=0;
}
for(Monster&m:MONSTER_LIST){
if(iframe_time==0&&OnUpperLevel()==m.OnUpperLevel()&&geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(m.GetPos(),12*m.GetSizeMult()/2))){
if(m.IsAlive()){

@ -12,11 +12,11 @@ INCLUDE_game
std::string Ranger::name="Ranger";
Class Ranger::cl=RANGER;
Ability Ranger::rightClickAbility={"Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE};
Ability Ranger::ability1={"Rapid Fire",12,35};
Ability Ranger::ability2={"Charged Shot",15,40};
Ability Ranger::ability3={"Multishot",25,50};
Ability Ranger::ability4={"???",0,0};
Ability Ranger::rightClickAbility=Ability("Retreat",7,0,VERY_DARK_BLUE,DARK_BLUE);
Ability Ranger::ability1=Ability("Rapid Fire",12,35);
Ability Ranger::ability2=Ability("Charged Shot",15,40);
Ability Ranger::ability3=Ability("Multishot",25,50);
Ability Ranger::ability4=Ability("???",0,0);
AnimationState Ranger::idle_n=RANGER_IDLE_N;
AnimationState Ranger::idle_e=RANGER_IDLE_E;
AnimationState Ranger::idle_s=RANGER_IDLE_S;

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

Loading…
Cancel
Save