var bulletSpeed = 9; var bulletReady = true; var bulletDelay = 150; var bulletArray = []; var bulletCount = 0; function createBullets(){ var bulletMc = this.attachMovie("bullet1", "bullet1"+bulletCount, 1000+bulletCount); bulletCount++; bulletMc._x = shipMc._x+(shipMc._width/2)-(bulletMc._width/2); bulletMc._y = shipMc._y+bulletMc._height; bulletArray.push(bulletMc); } function moveBullets(){ if(bulletReady && Key.isDown(Key.SPACE)){ trace(bulletArray.length); bulletReady = false; currentTime = getTimer(); createBullets(); } else { if(currentTime+bulletDelay<=getTimer()){ bulletReady = true } } for(var i = 0; i-50) { b._y -= bulletSpeed; } else { removeMovieClip(b); bulletArray.splice(i, 1); } if (!hit) { if(b.hitTest(ob)) { hit = true; ob.play(); removeMovieClip(b); bulletArray.splice(i, 1); } } } } var hit = false; var obSpeed = 2; function createObject(o) { ob = this.attachMovie(o, o, 100); ob._x = random(180)+20; } function resetObject() { ob._x = random(180)+20; ob._y = -40; ob.gotoAndStop(1); ob.restart = false; hit = false } function moveObject() { if (ob._y<250) { ob._y += obSpeed; } else { resetObject(); } if (ob.restart) { resetObject(); } } createObject("asteroid"); this.onEnterFrame = function(){ moveShip(); moveBullets(); moveObject(); };