From d494be6970c12ebb1ea040b69681d81824c3935b Mon Sep 17 00:00:00 2001 From: "sigonasr2, Sig, Sigo" Date: Fri, 7 Jul 2023 19:48:45 +0000 Subject: [PATCH] Added collision checks and interactions based on upper/lower level status. --- .vscode/settings.json | 9 ++++++++- Crawler/Class.cpp | 1 + Crawler/Crawler.cpp | 10 ++++++---- Crawler/Crawler.h | 2 +- Crawler/Player.cpp | 7 ++++++- Crawler/Player.h | 1 + Crawler/olcPixelGameEngine.h | 11 +++++++++-- 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 36a8d2be..e617935c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -80,6 +80,13 @@ "locale": "cpp", "queue": "cpp", "stack": "cpp", - "span": "cpp" + "span": "cpp", + "cfenv": "cpp", + "complex": "cpp", + "set": "cpp", + "__tree": "cpp", + "bitset": "cpp", + "regex": "cpp", + "valarray": "cpp" } } \ No newline at end of file diff --git a/Crawler/Class.cpp b/Crawler/Class.cpp index 713fad4c..5d820128 100644 --- a/Crawler/Class.cpp +++ b/Crawler/Class.cpp @@ -70,6 +70,7 @@ bool Warrior::AutoAttack(){ float closest_dist=999999; for(Monster&m:MONSTER_LIST){ if(m.IsAlive() + &&m.OnUpperLevel()==p.OnUpperLevel() &&geom2d::overlaps(geom2d::circle(p.pos-vf2d{p.GetSizeMult()*12,p.GetSizeMult()*12},p.attack_range*p.GetSizeMult()*12),geom2d::circle(m.GetPos()-vf2d{m.GetSizeMult()*12,m.GetSizeMult()*12},m.GetSizeMult()*12)) &&geom2d::line(game->GetWorldMousePos(),m.GetPos()).length()(game->GetWorldMousePos(),m.GetPos()).length(); diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index cdfeb0d8..5440982b 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -33,6 +33,8 @@ bool Crawler::OnUserCreate(){ InitializeLevel("assets/Campaigns/1_1_test.tmx",CAMPAIGN_1_1); + ConsoleCaptureStdOut(true); + ClassData::InitializeClassData(); //Initialize Camera. @@ -644,7 +646,7 @@ void Crawler::UpdateBullets(float fElapsedTime){ if(!b->deactivated){ if(b->friendly){ for(Monster&m:MONSTER_LIST){ - if(geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){ + if(b->OnUpperLevel()==m.OnUpperLevel()&&geom2d::overlaps(geom2d::circle(m.GetPos(),12*m.GetSizeMult()),geom2d::circle(b->pos,b->radius))){ if(b->hitList.find(&m)==b->hitList.end()&&m.Hurt(b->damage)){ if(!b->hitsMultiple){ if(b->MonsterHit(m)){ @@ -660,7 +662,7 @@ void Crawler::UpdateBullets(float fElapsedTime){ } } } else { - if(geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){ + if(b->OnUpperLevel()==player.OnUpperLevel()&&geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){ if(player.Hurt(b->damage)){ if(b->PlayerHit(player)){ it=BULLET_LIST.erase(it); @@ -695,9 +697,9 @@ void Crawler::UpdateBullets(float fElapsedTime){ outsidePlayerBulletLoop: int a; } -void Crawler::HurtEnemies(vf2d pos,float radius,int damage){ +void Crawler::HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel){ for(Monster&m:MONSTER_LIST){ - if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m.GetPos(),12*m.GetSizeMult()))){ + if(m.OnUpperLevel()==upperLevel&&geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m.GetPos(),12*m.GetSizeMult()))){ m.Hurt(damage); } } diff --git a/Crawler/Crawler.h b/Crawler/Crawler.h index b77f8474..8b508b4e 100644 --- a/Crawler/Crawler.h +++ b/Crawler/Crawler.h @@ -61,7 +61,7 @@ public: void AddEffect(Effect foreground,Effect background); //If back is true, places the effect in the background void AddEffect(Effect foreground,bool back=false); - void HurtEnemies(vf2d pos,float radius,int damage); + void HurtEnemies(vf2d pos,float radius,int damage,bool upperLevel); vf2d GetWorldMousePos(); bool LeftHeld(); bool RightHeld(); diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index 1793db18..6752ccda 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -207,7 +207,8 @@ void Player::Update(float fElapsedTime){ SetState(NORMAL); spin_angle=0; z=0; - game->HurtEnemies(pos,3*12,GetAttack()*2.5); + float numb=4; + game->HurtEnemies(pos,3*12,GetAttack()*2.5,OnUpperLevel()); game->AddEffect(Effect{GetPos(),0.5,AnimationState::GROUND_SLAM_ATTACK_FRONT,upperLevel,1.33f,0.6f},Effect{GetPos(),0.5,AnimationState::GROUND_SLAM_ATTACK_BACK,upperLevel,1.33f,0.6f}); } if(lastAnimationFlip>0){ @@ -448,6 +449,10 @@ void Player::AddBuff(BuffType type,float duration,float intensity){ buffList.push_back(Buff{type,duration,intensity}); } +bool Player::OnUpperLevel(){ + return upperLevel; +} + std::vectorPlayer::GetBuffs(BuffType buff){ std::vectorfilteredBuffs; std::copy_if(buffList.begin(),buffList.end(),std::back_inserter(filteredBuffs),[buff](Buff&b){return b.type==buff;}); diff --git a/Crawler/Player.h b/Crawler/Player.h index 122010e9..d51ae90c 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -102,6 +102,7 @@ struct Player{ Animate2D::Frame GetFrame(); Key GetLastReleasedMovementKey(); float GetSwordSwingTimer(); + bool OnUpperLevel(); float GetAbility2Cooldown(); float GetRightClickCooldown(); diff --git a/Crawler/olcPixelGameEngine.h b/Crawler/olcPixelGameEngine.h index 4d24f06d..e8731404 100644 --- a/Crawler/olcPixelGameEngine.h +++ b/Crawler/olcPixelGameEngine.h @@ -3574,10 +3574,10 @@ namespace olc vConsoleCursor.y++; vConsoleCursor.x = 0; } - if (vConsoleCursor.y >= vConsoleSize.y) + if (vConsoleCursor.y >= 1000) { vConsoleCursor.y = vConsoleSize.y - 1; - for (size_t i = 1; i < vConsoleSize.y; i++) + for (size_t i = 1; i < 1000; i++) sConsoleLines[i - 1] = sConsoleLines[i]; sConsoleLines[vConsoleCursor.y].clear(); } @@ -3590,6 +3590,13 @@ namespace olc TypeCharacter(c); } + if(GetMouseWheel()>0||GetKey(olc::PG_UP).bPressed)){ + nConsoleScroll=std::clamp(nConsoleScroll+vConsoleSize.y,0,1000-vConsoleSize.y); + } else + if(GetMouseWheel()<0||GetKey(olc::PG_DN).bPressed)){ + nConsoleScroll=std::clamp(nConsoleScroll-vConsoleSize.y,0,1000-vConsoleSize.y); + } + // Draw Shadow GradientFillRectDecal({ 0,0 }, olc::vf2d(vScreenSize), olc::PixelF(0, 0, 0.5f, 0.5f), olc::PixelF(0, 0, 0.25f, 0.5f), olc::PixelF(0, 0, 0.25f, 0.5f), olc::PixelF(0, 0, 0.25f, 0.5f));