|
|
|
@ -17,8 +17,8 @@ std::map<AnimationState,Animate2D::FrameSequence>ANIMATION_DATA; |
|
|
|
|
std::vector<Monster>MONSTER_LIST; |
|
|
|
|
std::vector<MonsterSpawner>SPAWNER_LIST; |
|
|
|
|
std::vector<DamageNumber>DAMAGENUMBER_LIST; |
|
|
|
|
std::vector<Bullet>BULLET_LIST; |
|
|
|
|
std::vector<Bullet>PLAYER_BULLET_LIST; |
|
|
|
|
std::vector<std::unique_ptr<Bullet>>BULLET_LIST; |
|
|
|
|
std::vector<std::unique_ptr<Bullet>>PLAYER_BULLET_LIST; |
|
|
|
|
Crawler*game; |
|
|
|
|
|
|
|
|
|
Crawler::Crawler() |
|
|
|
@ -591,64 +591,64 @@ void Crawler::UpdateEffects(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void Crawler::UpdateBullets(float fElapsedTime){ |
|
|
|
|
for(std::vector<Bullet>::iterator it=BULLET_LIST.begin();it!=BULLET_LIST.end();++it){ |
|
|
|
|
Bullet&b=*it; |
|
|
|
|
b.Update(fElapsedTime); |
|
|
|
|
b.pos+=b.vel*fElapsedTime; |
|
|
|
|
if(geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b.pos,b.radius))){ |
|
|
|
|
if(player.Hurt(b.damage)){ |
|
|
|
|
for(auto it=BULLET_LIST.begin();it!=BULLET_LIST.end();++it){ |
|
|
|
|
Bullet*b=dynamic_cast<Bullet*>((*it).get()); |
|
|
|
|
b->Update(fElapsedTime); |
|
|
|
|
b->pos+=b->vel*fElapsedTime; |
|
|
|
|
if(geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b->pos,b->radius))){ |
|
|
|
|
if(player.Hurt(b->damage)){ |
|
|
|
|
it=BULLET_LIST.erase(it); |
|
|
|
|
if(it==BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(b.pos.x<view.GetWorldTL().x||b.pos.x>view.GetWorldBR().x||b.pos.y<view.GetWorldTL().y||b.pos.y>view.GetWorldBR().y){ |
|
|
|
|
if(b->pos.x<view.GetWorldTL().x||b->pos.x>view.GetWorldBR().x||b->pos.y<view.GetWorldTL().y||b->pos.y>view.GetWorldBR().y){ |
|
|
|
|
it=BULLET_LIST.erase(it); |
|
|
|
|
if(it==BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
b.lifetime-=fElapsedTime; |
|
|
|
|
if(b.lifetime<=0){ |
|
|
|
|
b->lifetime-=fElapsedTime; |
|
|
|
|
if(b->lifetime<=0){ |
|
|
|
|
it=BULLET_LIST.erase(it); |
|
|
|
|
if(it==BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
b.animation.UpdateState(b.internal_animState,fElapsedTime); |
|
|
|
|
b->animation.UpdateState(b->internal_animState,fElapsedTime); |
|
|
|
|
} |
|
|
|
|
for(std::vector<Bullet>::iterator it=PLAYER_BULLET_LIST.begin();it!=PLAYER_BULLET_LIST.end();++it){ |
|
|
|
|
Bullet&b=*it; |
|
|
|
|
b.Update(fElapsedTime); |
|
|
|
|
b.pos+=b.vel*fElapsedTime; |
|
|
|
|
for(std::vector<std::unique_ptr<Bullet>>::iterator it=PLAYER_BULLET_LIST.begin();it!=PLAYER_BULLET_LIST.end();++it){ |
|
|
|
|
std::unique_ptr<Bullet>&b=*it; |
|
|
|
|
b->Update(fElapsedTime); |
|
|
|
|
b->pos+=b->vel*fElapsedTime; |
|
|
|
|
for(Monster&m:MONSTER_LIST){ |
|
|
|
|
if(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(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){ |
|
|
|
|
it=PLAYER_BULLET_LIST.erase(it); |
|
|
|
|
if(it==PLAYER_BULLET_LIST.end()){ |
|
|
|
|
goto outsidePlayerBulletLoop; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
b.hitList[&m]=true; |
|
|
|
|
b->hitList[&m]=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(b.pos.x<view.GetWorldTL().x||b.pos.x>view.GetWorldBR().x||b.pos.y<view.GetWorldTL().y||b.pos.y>view.GetWorldBR().y){ |
|
|
|
|
if(b->pos.x<view.GetWorldTL().x||b->pos.x>view.GetWorldBR().x||b->pos.y<view.GetWorldTL().y||b->pos.y>view.GetWorldBR().y){ |
|
|
|
|
it=PLAYER_BULLET_LIST.erase(it); |
|
|
|
|
if(it==PLAYER_BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
b.lifetime-=fElapsedTime; |
|
|
|
|
if(b.lifetime<=0){ |
|
|
|
|
b->lifetime-=fElapsedTime; |
|
|
|
|
if(b->lifetime<=0){ |
|
|
|
|
it=PLAYER_BULLET_LIST.erase(it); |
|
|
|
|
if(it==PLAYER_BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
b.animation.UpdateState(b.internal_animState,fElapsedTime); |
|
|
|
|
b->animation.UpdateState(b->internal_animState,fElapsedTime); |
|
|
|
|
} |
|
|
|
|
outsidePlayerBulletLoop: |
|
|
|
|
int a; |
|
|
|
@ -715,11 +715,11 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
for(Effect&e:foregroundEffects){ |
|
|
|
|
e.Draw(); |
|
|
|
|
} |
|
|
|
|
for(Bullet&b:BULLET_LIST){ |
|
|
|
|
b.Draw(); |
|
|
|
|
for(std::unique_ptr<Bullet>&b:BULLET_LIST){ |
|
|
|
|
b->Draw(); |
|
|
|
|
} |
|
|
|
|
for(Bullet&b:PLAYER_BULLET_LIST){ |
|
|
|
|
b.Draw(); |
|
|
|
|
for(std::unique_ptr<Bullet>&b:PLAYER_BULLET_LIST){ |
|
|
|
|
b->Draw(); |
|
|
|
|
} |
|
|
|
|
for(TileGroup&group:foregroundTileGroups){ |
|
|
|
|
if(geom2d::overlaps(group.GetRange(),player.pos)){ |
|
|
|
|