|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
#include "Crawler.h" |
|
|
|
|
#include "olcUTIL_Camera2D.h" |
|
|
|
|
#include "DamageNumber.h" |
|
|
|
|
#include "Bullet.h" |
|
|
|
|
#include "DEFINES.h" |
|
|
|
|
|
|
|
|
|
//192x192
|
|
|
|
@ -10,6 +11,7 @@ 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; |
|
|
|
|
Crawler*game; |
|
|
|
|
|
|
|
|
|
Crawler::Crawler() |
|
|
|
@ -78,6 +80,7 @@ bool Crawler::OnUserUpdate(float fElapsedTime){ |
|
|
|
|
for(Monster&m:MONSTER_LIST){ |
|
|
|
|
m.Update(fElapsedTime); |
|
|
|
|
} |
|
|
|
|
UpdateBullets(fElapsedTime); |
|
|
|
|
UpdateCamera(fElapsedTime); |
|
|
|
|
RenderWorld(fElapsedTime); |
|
|
|
|
RenderHud(); |
|
|
|
@ -322,6 +325,25 @@ 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.pos+=b.vel*fElapsedTime; |
|
|
|
|
if(geom2d::overlaps(geom2d::circle(player.GetPos(),12*player.GetSizeMult()/2),geom2d::circle(b.pos,b.radius))){ |
|
|
|
|
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){ |
|
|
|
|
it=BULLET_LIST.erase(it); |
|
|
|
|
if(it==BULLET_LIST.end()){ |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
void Crawler::HurtEnemies(vf2d pos,float radius,int damage){ |
|
|
|
|
for(Monster&m:MONSTER_LIST){ |
|
|
|
|
if(geom2d::overlaps(geom2d::circle(pos,radius),geom2d::circle(m.GetPos(),12*m.GetSizeMult()))){ |
|
|
|
@ -362,6 +384,10 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
for(Effect&e:foregroundEffects){ |
|
|
|
|
e.Draw(); |
|
|
|
|
} |
|
|
|
|
for(Bullet&b:BULLET_LIST){ |
|
|
|
|
view.FillCircle(b.pos,b.radius,b.col); |
|
|
|
|
view.DrawCircle(b.pos,b.radius,WHITE,0xAA); |
|
|
|
|
} |
|
|
|
|
for(std::vector<DamageNumber>::iterator it=DAMAGENUMBER_LIST.begin();it!=DAMAGENUMBER_LIST.end();++it){ |
|
|
|
|
DamageNumber&dn=*it; |
|
|
|
|
dn.lifeTime+=fElapsedTime; |
|
|
|
|