xxxxxxxxxx
var sci;
var ai=[];
var ei=[];
var bi=[];
var explosions=[];
var sc;
var asteroids=[];
var bubbles=[];
var baseacc=.1;
var lost=false;
var button;
var lvl;
var score;
var laserSpeed=10;
function preload() {
sci = loadImage('spaceship01.png');
for (var i=0; i<48; i++) {
if (i<10)ai[i]=loadImage('a0'+i+'.png');
else ai[i]=loadImage('a'+i+'.png');
}
for (var i=0; i<9; i++) {
ei[i]=loadImage('e0'+i+'.png');
}
for (var i=0; i<6; i++) {
bi[i]=loadImage('b0'+i+'.png');
}
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(0);
imageMode(CENTER);
asteroids=[];
bubbles=[];
score=0;
lvl=1;
sc=new Spaceship(createVector(width/2, height/2));
asteroids.push(new Asteroid(0, 6, 150, createVector(random(width), random(height))));
}
function draw() {
background(0);
fill(255);
text("Score: "+score,50,50);
text("Speed:",50,70);
rect(50,75,baseacc*200,10);
text("Shooting speed:",50,100);
rect(50,105,.1*(650-sc.lasertimegap),10);
if (!lost) {
if (random(1)>.995)bubbles.push(new Bubble(int(random(6)), createVector(random(width), random(height))));
sc.update();
sc.display();
for (var i=0; i<asteroids.length; i++) {
asteroids[i].update();
asteroids[i].display();
}
for (var i=0; i<explosions.length; i++) {
explosions[i].display();
}
for (var i=0; i<bubbles.length; i++) {
bubbles[i].update();
bubbles[i].display();
}
}
}
function replay() {
console.log(button);
lost=false;
removeElements();
setup();
}