let shots = [];

stages.push({
	id: "mining-asteroid-field",
	setup: () => {
        shots = [];
		getSet('starfield').setup();
		starMotion.velocity.x = 0.05;
        starMotion.velocity.y = 0.05;
        getSet('asteroid-field').setup();
        shots.push({x: 0, y: -30, velocity: {x: 0, y: -12}});
	},
	update: (delta) => {
		getSet('starfield').update(delta);
        getSet('asteroid-field').update(delta);
        let shootAnother = false;
        shots.forEach(shot => {
            shot.x += shot.velocity.x;
            shot.y += shot.velocity.y;
            if(!shootAnother && shots.length < 5 && shot.y < -250) {
                shootAnother = true;
            }
            if(shootAnother && shot.y > -200) {
                shootAnother = false;
            }
        });

        if(shootAnother) {
            shots.push({x: 0, y: -30, velocity: {x: 0, y: -12}});
        }

        shots = shots.filter(shot => shot.y > -400);
	},
	draw: (context, delta) => {
		getSet('starfield').draw(context, delta);
        getSet('asteroid-field').draw(context, delta);
        
        shots.forEach(shot => {
            atlas.drawCentered(context, "laserBlue12.png", { x: shot.x, y: shot.y });
        });

		atlas.drawCentered(context, userData.sprite, { x: 0, y: 0 });
	},
	cleanup: () => {
        shots = [];
	},
});