home *** CD-ROM | disk | FTP | other *** search
- function startLevel()
- {
- ship.dx = 0;
- ship.dy = 0;
- bullets = new Array();
- rocks = new Array();
- level = 0;
- i = 0;
- while(i < gameLevel + 1)
- {
- newRock(100,0,0);
- i++;
- }
- timeOfLastFire = 0;
- score = 0;
- }
- function shipTurn(amt)
- {
- ship._rotation += amt;
- }
- function shipThrust()
- {
- ship.dx += Math.cos(6.283185307179586 * (ship._rotation - 90) / 360);
- ship.dy += Math.sin(6.283185307179586 * (ship._rotation - 90) / 360);
- if(ship.dy > 18)
- {
- ship.dy = 18;
- }
- if(ship.dx > 18)
- {
- ship.dx = 18;
- }
- if(ship.dy < -18)
- {
- ship.dy = -18;
- }
- if(ship.dx < -18)
- {
- ship.dx = -18;
- }
- ship.gotoAndPlay("thrust");
- }
- function shipBreak()
- {
- ship.dx *= 0.5;
- ship.dy *= 0.5;
- }
- function shipFire()
- {
- if(timeOfLastFire + 200 < getTimer())
- {
- timeOfLastFire = getTimer();
- level++;
- attachMovie("bullet","bullet" + level,level);
- clip = _root["bullet" + level];
- clip._x = ship._x;
- clip._y = ship._y;
- clip.dx = 10 * Math.cos(6.283185307179586 * (ship._rotation - 90) / 360);
- clip.dy = 10 * Math.sin(6.283185307179586 * (ship._rotation - 90) / 360);
- bullets.push(clip);
- }
- }
- function shipMove()
- {
- ship._x += ship.dx;
- if(ship._x > 550)
- {
- ship._x -= 550;
- }
- if(ship._x < 0)
- {
- ship._x += 550;
- }
- ship._y += ship.dy;
- if(ship._y > 400)
- {
- ship._y -= 400;
- }
- if(ship._y < 0)
- {
- ship._y += 400;
- }
- }
- function bulletsMove()
- {
- i = bullets.length - 1;
- while(i >= 0)
- {
- bullets[i]._x += bullets[i].dx;
- bullets[i]._y += bullets[i].dy;
- if(bullets[i]._x > 550 or bullets[i]._x < 0 or bullets[i]._y > 400 or bullets[i]._y < 0)
- {
- bullets[i].removeMovieClip();
- bullets.splice(i,1);
- }
- i--;
- }
- }
- function newRock(size, x, y)
- {
- level++;
- rockNum = int(Math.random() * 3 + 1);
- attachMovie("rock" + rockNum,"rock" + level,level);
- clip = _root["rock" + level];
- clip._x = x;
- clip._y = y;
- clip._xscale = size;
- clip._yscale = size;
- clip.dx = Math.Random() * gameLevel + 0.5;
- if(Math.random() < 0.5)
- {
- clip.dx *= -1;
- }
- clip.dy = Math.Random() * gameLevel + 0.5;
- if(Math.random() < 0.5)
- {
- clip.dy *= -1;
- }
- clip.spin = Math.random() * 6 - 3;
- rocks.push(clip);
- }
- function rocksMove()
- {
- i = rocks.length - 1;
- while(i >= 0)
- {
- clip = rocks[i].clip;
- rocks[i]._x += rocks[i].dx;
- if(rocks[i]._x > 550)
- {
- rocks[i]._x -= 550;
- }
- if(rocks[i]._x < 0)
- {
- rocks[i]._x += 550;
- }
- rocks[i]._y += rocks[i].dy;
- if(rocks[i]._y > 400)
- {
- rocks[i]._y -= 400;
- }
- if(rocks[i]._y < 0)
- {
- rocks[i]._y += 400;
- }
- rocks[i]._rotation += rocks[i].spin;
- i--;
- }
- }
- function checkHits()
- {
- i = rocks.length - 1;
- while(i >= 0)
- {
- j = bullets.length - 1;
- while(j >= 0)
- {
- if(rocks[i].hitTest(bullets[j]._x,bullets[j]._y,true))
- {
- if(rocks[1])
- {
- bleat.start();
- }
- else
- {
- bleat2.start();
- }
- bullets[j].removeMovieClip();
- bullets.splice(j,1);
- if(rocks[i]._xscale == 100)
- {
- if(multi50 == 0 && multi25 == 0)
- {
- multi++;
- }
- else
- {
- multi = 0;
- }
- multi50 = 0;
- multi25 = 0;
- multi100++;
- }
- else if(rocks[i]._xscale == 50)
- {
- if(multi100 == 0 && multi25 == 0)
- {
- multi++;
- }
- else
- {
- multi = 0;
- }
- multi100 = 0;
- multi25 = 0;
- multi50++;
- }
- else if(rocks[i]._xscale == 25)
- {
- if(multi50 == 0 && multi100 == 0)
- {
- multi++;
- }
- else
- {
- multi = 0;
- }
- multi50 = 0;
- multi100 = 0;
- multi25++;
- }
- if(multipause == false)
- {
- multilights.gotoAndPlay(multi + 1);
- }
- newsize = rocks[i]._xscale / 2;
- x = rocks[i]._x;
- y = rocks[i]._y;
- rocks[i].removeMovieClip();
- rocks.splice(i,1);
- if(newsize >= 25)
- {
- newRock(newsize,x,y);
- newRock(newsize,x,y);
- }
- score += 10;
- break;
- }
- j--;
- }
- if(rocks[i].hitTest(ship._x + 8,ship._y + 8,true) || rocks[i].hitTest(ship._x - 8,ship._y + 8,true) || rocks[i].hitTest(ship._x + 8,ship._y - 8,true) || rocks[i].hitTest(ship._x - 8,ship._y - 8,true))
- {
- ship.gotoAndPlay("hit");
- }
- i--;
- }
- if(rocks.length == 0)
- {
- removeAll();
- gotoAndPlay(38);
- gameLevel++;
- }
- }
- function removeAll()
- {
- i = 0;
- while(i < bullets.length)
- {
- bullets[i].removeMovieClip();
- i++;
- }
- i = 0;
- while(i < rocks.length)
- {
- rocks[i].removeMovieClip();
- i++;
- }
- }
- stop();
- _root.removeAll();
- multi = 0;
- multiplier = 1;
- multi100 = 0;
- multi50 = 0;
- multi25 = 0;
- multipause = false;
- livesclip.gotoAndStop(lives);
- bleat = new Sound();
- bleat.attachSound("bleat");
- bleat2 = new Sound();
- bleat2.attachSound("bleat2");
-