home *** CD-ROM | disk | FTP | other *** search
- function hit(rad1, rad2, dist)
- {
- if(Math.abs(dist) < rad1 + rad2)
- {
- trace("rad1=" + rad1);
- trace("rad2=" + rad2);
- trace("dist=" + dist);
- }
- return Math.abs(dist) < rad1 + rad2;
- }
- onEnterFrame = function()
- {
- movePlane();
- handleVolume();
- };
- movePlane = function()
- {
- if(!gameover)
- {
- if(!plane.hit)
- {
- time = int((getTimer() - startTime) / 100) / 10;
- var my = _ymouse;
- my = Math.min(my,325);
- my = Math.max(my,30);
- var fr = int(_ymouse / 15);
- var goal = (my - plane._y) * 0.09;
- plane.gotoAndStop(fr + 8);
- plane._y += goal;
- if(goal < 5)
- {
- plane._y += Math.sin(x) * 2;
- x += 0.1;
- }
- else
- {
- x = 0;
- }
- }
- else
- {
- goal = (500 - plane._y) * 0.03;
- plane._y += goal;
- if(plane._Y > 425)
- {
- doGameover();
- }
- }
- plane._rotation = goal;
- shadow._alpha = my / 4 * 0.3;
- shadow._xscale = shadow._yscale = 100 + (400 - my) * 0.1;
- shadow._x = plane._x + (400 - my) * 0.1;
- ball0._y = plane._y;
- }
- };
- reset = function()
- {
- for(prop in _root.soundholder)
- {
- _root.soundholder[prop].soundname.stop();
- }
- soundHolder.theme.soundname.stop();
- soundHolder.prop.soundname.stop();
- _root.mainSound = new Sound(_root);
- _root.mainSound.setVolume(100);
- _global.soundCount = 1000000;
- _global.vol = 100;
- removeMovieClip(soundHolder);
- createEmptyMovieClip("soundHolder",1000);
- startTheme();
- scores._visible = false;
- _global.thememuted = false;
- time = 0;
- startTime = getTimer();
- v = setInterval(thunder,10000);
- v2 = setInterval(ufo,1000);
- blocker.gotoAndStop(1);
- ufocount = 0;
- gameover = false;
- soundHolder.prop.soundname.stop();
- playSound("prop","prop",1000,0);
- plane.hit = false;
- plane._y = 200;
- replay.gotoAndStop(1);
- ocean.play();
- rain.play();
- };
- handleScore = function()
- {
- scores.scripting.test(time);
- };
- doGameover = function()
- {
- stopTheme();
- soundHolder.prop.soundname = null;
- ocean.stop();
- rain.stop();
- clearInterval(v2);
- clearInterval(v);
- playSound("crash","crash",1,0);
- playSound("splash","splash",1,0);
- gameover = true;
- var i = 1;
- while(i < 2000)
- {
- removeMovieClip(eval("ball" + i));
- removeMovieClip(eval("ufo" + i));
- i++;
- }
- blocker.gotoAndPlay(2);
- scores._visible = true;
- };
- playReset = function()
- {
- replay.gotoAndPlay(2);
- };
- thunder = function()
- {
- lightning.play();
- playSound("storm","storm",1,0);
- };
- ufo = function()
- {
- clearInterval(v2);
- v2 = setInterval(ufo,1000 - ufocount * 2);
- ufocount++;
- attachMovie("ufo","ufo" + ufocount,10000 + ufocount);
- attachMovie("ball","ball" + ufocount,12000 + ufocount);
- var mc = eval("ufo" + ufocount);
- var ball = eval("ball" + ufocount);
- mc.ball = ball;
- mc._x = 415 + random(50);
- mc._y = random(300) + 50;
- mc.speed = 14 + int(ufocount / 5) + random(6);
- mc.scale = 100 - (400 - mc._y) * 0.1;
- mc._xscale = mc._yscale = mc.scale;
- mc.ball._xscale = mc.ball._yscale = mc.scale * 0.9;
- mc.onEnterframe = function()
- {
- if(!gameover and mc.inPlace)
- {
- if(hit(ball0._width / 2,mc.ball._width / 2,distance(ball0._x,ball0._y,mc.ball._x,mc.ball._y)) and !plane.hit)
- {
- plane.hit = true;
- plane.fire.play();
- soundHolder.prop.soundname.stop();
- playSound("zoop","zoop",1,0);
- playSound("sputter","sputter",1,2.5);
- }
- mc.ball._y = mc._y;
- mc.ball._x = mc._x - 11;
- mc._x -= mc.speed;
- if(mc._x < -150)
- {
- mc.onEnterframe = null;
- removeMovieClip(mc);
- }
- }
- };
- };
- distance = function(x1, y1, x2, y2)
- {
- return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
- };
- removeMovieClip(soundHolder);
- createEmptyMovieClip("soundHolder",1000);
- _global.playSound = function(targetSound, soundnameclip, loops, offset)
- {
- removeMovieClip(targetSound);
- _root.soundHolder.createEmptyMovieClip(targetSound,1000 + _global.soundCount);
- for(prop in _root.soundholder)
- {
- if(typeof _root.soundholder[prop] == "movieclip")
- {
- if(_root.soundholder[prop].soundname == undefined)
- {
- _root.soundholder[prop].soundname = new Sound(soundholder[prop]);
- _root.soundholder[prop].soundname.attachSound(targetSound);
- _root.soundholder[prop].soundname.start(offset,loops);
- }
- }
- }
- };
- _global.handleVolume = function()
- {
- soundHolder.onEnterFrame = function()
- {
- var inc = 7.5;
- if(_global.muted)
- {
- dir = - inc;
- }
- else
- {
- dir = inc;
- }
- _global.vol += dir;
- _global.vol = Math.max(_global.vol,0);
- _global.vol = Math.min(_global.vol,100);
- _root.mainSound.setVolume(_global.vol);
- if(thememuted)
- {
- themedir -= inc;
- }
- else
- {
- themedir += inc;
- }
- themedir = Math.max(themedir,0);
- themedir = Math.min(themedir,100);
- soundHolder.theme.soundname.setVolume(themedir);
- };
- };
- handleVolume();
- _global.startTheme = function()
- {
- soundHolder.createEmptyMovieClip("theme",1000);
- soundHolder.theme.soundname = new Sound(soundHolder);
- soundHolder.theme.soundname.attachSound("theme");
- soundHolder.theme.soundname.setVolume(0);
- soundHolder.theme.soundname.start(0,1000);
- };
- _global.stopTheme = function()
- {
- _global.thememuted = true;
- };
- _global.unMute = function()
- {
- _global.muted = false;
- };
- reset();
-