Added collision checks and interactions based on upper/lower level status.

pull/28/head
parent 85af67fa60
commit d494be6970
  1. 9
      .vscode/settings.json
  2. 1
      Crawler/Class.cpp
  3. 10
      Crawler/Crawler.cpp
  4. 2
      Crawler/Crawler.h
  5. 7
      Crawler/Player.cpp
  6. 1
      Crawler/Player.h
  7. 11
      Crawler/olcPixelGameEngine.h

@ -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"
}
}

@ -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<float>(p.pos-vf2d{p.GetSizeMult()*12,p.GetSizeMult()*12},p.attack_range*p.GetSizeMult()*12),geom2d::circle<float>(m.GetPos()-vf2d{m.GetSizeMult()*12,m.GetSizeMult()*12},m.GetSizeMult()*12))
&&geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length()<closest_dist){
closest_dist=geom2d::line<float>(game->GetWorldMousePos(),m.GetPos()).length();

@ -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);
}
}

@ -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();

@ -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::vector<Buff>Player::GetBuffs(BuffType buff){
std::vector<Buff>filteredBuffs;
std::copy_if(buffList.begin(),buffList.end(),std::back_inserter(filteredBuffs),[buff](Buff&b){return b.type==buff;});

@ -102,6 +102,7 @@ struct Player{
Animate2D::Frame GetFrame();
Key GetLastReleasedMovementKey();
float GetSwordSwingTimer();
bool OnUpperLevel();
float GetAbility2Cooldown();
float GetRightClickCooldown();

@ -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));

Loading…
Cancel
Save