diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index fac4e2df..8270c3fd 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -341,7 +341,7 @@ void Crawler::UpdateEffects(float fElapsedTime){ Effect*e=(*it).get(); if(!e->Update(fElapsedTime)){ it=backgroundEffects.erase(it); - if(it==backgroundEffects.end()){ + if(it==backgroundEffects.end()){//In case we added effects to the vector and the vector has shifted in memory, we prematurely end. break; } } @@ -350,11 +350,20 @@ void Crawler::UpdateEffects(float fElapsedTime){ Effect*e=(*it).get(); if(!e->Update(fElapsedTime)){ it=foregroundEffects.erase(it); - if(it==foregroundEffects.end()){ + if(it==foregroundEffects.end()){//In case we added effects to the vector and the vector has shifted in memory, we prematurely end. break; } } } + + for(auto it=foregroundEffectsToBeInserted.begin();it!=foregroundEffectsToBeInserted.end();++it){ + foregroundEffects.push_back(std::move(*it)); + } + for(auto it=backgroundEffectsToBeInserted.begin();it!=backgroundEffectsToBeInserted.end();++it){ + backgroundEffects.push_back(std::move(*it)); + } + foregroundEffectsToBeInserted.clear(); + backgroundEffectsToBeInserted.clear(); } void Crawler::UpdateBullets(float fElapsedTime){ for(auto it=BULLET_LIST.begin();it!=BULLET_LIST.end();++it){ @@ -742,15 +751,15 @@ void Crawler::RenderHud(){ } void Crawler::AddEffect(std::unique_ptrforeground,std::unique_ptr background){ - foregroundEffects.push_back(std::move(foreground)); - backgroundEffects.push_back(std::move(background)); + AddEffect(std::move(background),true); + AddEffect(std::move(foreground)); } void Crawler::AddEffect(std::unique_ptr foreground,bool back){ if(back){ - backgroundEffects.push_back(std::move(foreground)); + backgroundEffectsToBeInserted.push_back(std::move(foreground)); } else { - foregroundEffects.push_back(std::move(foreground)); + foregroundEffectsToBeInserted.push_back(std::move(foreground)); } } diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index 3a79c183..ad7a9fc7 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -36,7 +36,7 @@ public: static Key KEY_ABILITY3; static Key KEY_ABILITY4; private: - std::vector>foregroundEffects,backgroundEffects; + std::vector>foregroundEffects,backgroundEffects,foregroundEffectsToBeInserted,backgroundEffectsToBeInserted; std::mapMAP_DATA; std::mapMAP_TILESETS; vf2d worldShake={}; diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 64f4a6a1..44184cbe 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -204,7 +204,6 @@ - @@ -220,8 +219,13 @@ + + + + + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index c2fde05b..a4139623 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -140,9 +140,6 @@ Source Files - - Source Files - Source Files @@ -176,6 +173,21 @@ Source Files\Effects + + Source Files\Player Classes + + + Source Files\Player Classes + + + Source Files\Player Classes + + + Source Files\Player Classes + + + Source Files\Player Classes + diff --git a/Crawler/DEFINES.h b/Crawler/DEFINES.h index 3a67326a..3b2bdf7b 100644 --- a/Crawler/DEFINES.h +++ b/Crawler/DEFINES.h @@ -16,7 +16,7 @@ #define SETUP_CLASS(class) \ class::class(){InitializeClassAbilities();} \ class::class(Player*player) \ - :Player::Player(player){} \ + :Player::Player(player){InitializeClassAbilities();} \ Class class::GetClass(){return cl;} \ std::string class::GetClassName(){return name;} \ Ability&class::GetRightClickAbility(){return rightClickAbility;}; \ diff --git a/Crawler/Meteor.cpp b/Crawler/Meteor.cpp index 78b36514..300f0b76 100644 --- a/Crawler/Meteor.cpp +++ b/Crawler/Meteor.cpp @@ -14,11 +14,13 @@ bool Meteor::Update(float fElapsedTime){ if(lifetime<=0&&!shakeField){ shakeField=true; game->SetupWorldShake(2); - for(int i=0;i<360;i++){ - float randomAngle=2*PI; - float randomRange=192*size.x*(1-util::random(0.25))*(1-util::random(0.25)); + for(int i=0;i<650;i++){ + float randomAngle=util::random(2*PI); + float randomRange=100*size.x*(1-util::random(0.25))*(1-util::random(0.25)); + float randomColorTintG=256-(util::random(128)+util::random(128)); float randomColorTint=util::random(128); - game->AddEffect(std::make_unique(pos+vf2d{cos(randomAngle),sin(randomAngle)}*randomRange,0,AnimationState::DOT_PARTICLE,OnUpperLevel(),vf2d{util::random(2),util::random(3)},util::random(3)+1,vf2d{util::random(4)-2,-util::random(4)},Pixel{255,uint8_t(randomColorTint),uint8_t(randomColorTint),uint8_t(util::random(128)+128)},0,0,true)); + vf2d effectPos=pos+vf2d{cos(randomAngle),sin(randomAngle)}*randomRange-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}; + game->AddEffect(std::make_unique(effectPos,0,AnimationState::DOT_PARTICLE,OnUpperLevel(),vf2d{util::random(2)+1,util::random(3)+1},util::random(3)+1,vf2d{util::random(10)-5,-util::random(20)-5},Pixel{255,uint8_t(randomColorTintG),uint8_t(randomColorTint),uint8_t(util::random(128)+128)},0,0,true),effectPos.y<(pos-vf2d{0,GetFrame().GetSourceRect().size.y/2.f}).y); } } return Effect::Update(fElapsedTime); diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 6e02b15c..3999fcf8 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -20,8 +20,8 @@ Player::Player() :state(State::NORMAL),lastReleasedMovementKey(DOWN),facingDirection(DOWN){} Player::Player(Player*player) - :pos(player->GetPos()),vel(player->GetVelocity()),iframe_time(player->iframe_time),lastReleasedMovementKey(player->GetLastReleasedMovementKey()), - facingDirection(GetFacingDirection()){} + :pos(player->GetPos()),vel(player->GetVelocity()),iframe_time(player->iframe_time),lastReleasedMovementKey(DOWN), + facingDirection(DOWN),state(State::NORMAL){} bool Player::SetX(float x){ vf2d newPos={x,pos.y}; diff --git a/Crawler/Player.h b/Crawler/Player.h index 19982d52..8ac68b3b 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -67,7 +67,7 @@ protected: bool upperLevel=false; vf2d vel={0,0}; float attack_range=1.5f; - Key facingDirection; + Key facingDirection=DOWN; float swordSwingTimer=0; void CastSpell(Ability&ability); Ability*castPrepAbility; diff --git a/Crawler/Version.h b/Crawler/Version.h index a570bebf..1c9f3581 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 662 +#define VERSION_BUILD 686 #define stringify(a) stringify_(a) #define stringify_(a) #a