okay.
bool copsarehere=false,landerishere=false;
class heli
{
int x;
int loop;
timer releasetimer,movetimer;
heli()
{
releasetimer.pause();releasetimer.force(0);
movetimer.pause();movetimer.force(0);
}
int position()
{
return pool.play_2d("sounds/cop/helicopter_loop.ogg",playerx,0,this.x,30,true);
}
timer flyintimer;
int y=30;
bool coming=false;
void start()
{
this.x=random(0,boundary);
this.facing=random(1,2);
this.loop=this.position();
this.coming=true;
}
void fly_in()
{
if(this.y>10&&flyintimer.elapsed>=50)
{
y--;
pool.update_sound_2d(this.loop,this.x,y);
this.flyintimer.restart();
}
else this.coming=false;
}
int facing;
void move()
{
if(copsarehere==false) this.can_release=true;
if(this.facing==1)
{
if(this.x<0) this.facing++;
else
{
if(this.movetimer.elapsed>=60)
{
this.x--;
this.movetimer.restart();
}
}
}
else
{
if(this.x>boundary) this.facing--;
else
{
if(this.movetimer.elapsed>=60)
{
this.x++;
this.movetimer.restart();
}
}
}
pool.update_sound_2d(this.loop,this.x,this.y);
}
bool releasing=false,can_release=true;
int release()
{
releasing=true;
releasetimer.restart();
int tmp=pool.play_1d("sounds/cop/helicopter_release.ogg",playerx,this.x,false);
return pool.items[tmp].handle.length;
}
void dropit()
{
releasing=false;
can_release=false;
releasetimer.pause();releasetimer.force(0);
droplander(this.x);
}
}
class lander
{
int x,y=10, loop;
bool justreleased=true,landed=false;
timer falltimer;
lander(int x)
{
landerishere=true;
this.x=x;
}
void fall()
{
if(justreleased) {this.loop=pool.play_2d("sounds/cop/lander_loop.ogg",playerx,0,this.x,this.y,false);this.justreleased=false;}
if(this.y>0)
{
if(this.falltimer.elapsed>=100)
{
this.y--;
this.falltimer.restart();
pool.update_sound_2d(this.loop,this.x,this.y);
}
else
{
pool.destroy_sound(this.loop);
pool.play_1d("sounds/cop/lander_land.ogg",playerx,this.x,false);
this.landed=true;
landerishere=false;
this.spawn_cops();
}
}
}
void spawn_cops()
{
for(int i=1; i<5; i++)
{
cop tmp(random(this.x-10,this.x+10),i);
cops.insert_last(tmp);
}
copsarehere=true;
}
}
lander@[] lander_aray(1);
class cop
{
int hp,x,num,walkspeed,shootspeed;
timer walktimer,shoottimer;
cop(int x, int num)
{
this.num=num;
this.x=x;
this.hp=100;
this.walkspeed=random(230,400);
this.shootspeed=random(800,1600);
this.facing=random(1,2);
}
bool dead=false;
void hit(int damage)
{
if(this.jumping==jumping)
{
this.hp=this.hp-damage;
pool.play_1d("sounds/misc/bullet"+random(1,4)+".ogg",playerx,this.x);
if(this.hp<=0) this.die();
else pool.play_1d("sounds/cop/enemy/hit"+num+".ogg",playerx,this.x,false);
}
else return;
}
void die()
{
pool.play_1d("sounds/cop/enemy/die"+num+".ogg",playerx,this.x,false);
this.dead=true;
}
void shoot()
{
this.shoottime=random(800,1600);
pool.play_1d("sounds/cop/enemy/shoot"+num+".ogg",playerx,this.x,false);
if(this.inrange()==true)
{
pool.play_stationary("sounds/misc/bullet"+random(1,4)+".ogg",false);
playerhp=playerhp-random(5,15);
}
}
bool inrange()
{
if(this.facing==1&&playerx>=(this.x-5)&&playerx<=this.x) return true;
else if(this.facing==2&&playerx<=(this.x+5)&&playerx>=this.x) return true;
else return false;
}
timer jumptimer;
bool jumping=false;
int facing;
void jump()
{
this.jumping=true;
pool.play_1d("sounds/steps/jump.ogg",playerx,this.x,false);
this.airmovetimer.restart();
}
timer airmovetimer;
void check()
{
if(this.jumping==false)
{
if(this.shoottimer.elapsed>=this.shoottime) this.shoot();
if(this.x>playerx&&this.walktimer.elapsed>=this.walkspeed)
{
this.walktimer.restart();
this.x--;
this.facing=1;
pool.play_1d("sounds/steps/step"+random(1,20)+".ogg",playerx,this.x,false);
}
else if(this.x<playerx&&this.walktimer.elapsed>=this.walkspeed)
{
this.x++;
this.facing=2;
this.walktimer.restart();
pool.play_1d("sounds/steps/step"+random(1,20)+".ogg",playerx,this.x,false);
}
else if(this.x==playerx)
{
this.jumptimer.restart();
this.jump();
}
}
if(this.jumping==true)
{
if(this.jumptimer.elapsed>=1000)
{
this.jumping=false;
pool.play_1d("sounds/steps/land"+random(1,5)+".ogg",playerx,this.x,false);
}
else
{
if(this.x<playerx&&this.airmovetimer.elapsed>=random(60,100))
{
this.airmovetimer.restart();
this.x--;
this.facing=2;
}
else if(this.x>playerx&&this.airmovetimer.elapsed>=random(60,100))
{
this.x++;
this.facing=1;
this.airmovetimer.restart();
}
}
}
}
}
cop@[] cops;
void droplander((int x)
{
lander l(x);
lander_aray.insert_last(l);
return;
}
void landercheck()
{
if(lander_aray.is_empty==false)
{
if(lander[0].landed==true)
{
lander_aray.remove_at(0);
landerishere=false;
}
else
{
lander[0].fall();
}
}
}
void copcheck()
{
if(cops.length==0)
{
copsarehere=false;
return;
}
for(int i=0; i<cops.length; i++)
{
if(cops[i].dead==true)
{
cops.remove_at(i);
continue;
}
cops[i].check();
}
}
heli copter;
void helistuff()
[
copter.move();
if(copter.releasetimer.elapsed>=5068)
{
copter.dropit();
}
}