home *** CD-ROM | disk | FTP | other *** search
- class tgame
- {
- var commenti;
- var giudizi;
- var i;
- var maxgiudizio;
- var musicmc;
- var ballsoundmc;
- var ballsound;
- var bumpersoundmc;
- var bumpersound;
- var musicsound;
- var mymusicvol;
- var basecolortr;
- var mycolortr;
- var lastedtime;
- var myformat;
- var mymouse;
- var volumer;
- var gotoAndStop;
- var scritte;
- var balls;
- var deltat;
- var deltamult;
- var scrittefinealpha = 100;
- var olddeltatime = getTimer();
- var continousmusic = false;
- var realmaxballs = 15;
- var stoppingsound = false;
- var soundson = true;
- var maxgravity = 0.3;
- var maxspawntime = 50;
- var gametime = 0;
- var mousewasup = true;
- var mouseisdown = false;
- var screenw = 450;
- var screenh = 450;
- var currentballs = 0;
- var maxballs = 20;
- var fpstime = 0;
- var oldmillisecs = getTimer();
- var gamephase = 0;
- var gravity = 0;
- function tgame()
- {
- }
- function init(startsound)
- {
- this.commenti = new Array();
- this.commenti[3] = "EASY PEASY";
- this.commenti[4] = "STILL QUITE EASY";
- this.commenti[5] = "FUN BEGINS NOW";
- this.commenti[6] = "QUITE CHALLENGING";
- this.commenti[7] = "PRETTY TOUGH";
- this.commenti[8] = "VERY TRICKY";
- this.commenti[9] = "TERRIBLY HARD";
- this.commenti[10] = "INSANELY DIFFICULT";
- this.commenti[11] = "TOTALLY NUTS";
- this.commenti[12] = "INCREDIBLY CHALLENGING";
- this.commenti[13] = "ALMOST IMPOSSIBLE";
- this.commenti[14] = "UTTLERLY INCREDIBLE";
- this.commenti[15] = "TOTALLY IMPOSSIBLE";
- this.giudizi = new Array();
- this.i = 0;
- this.giudizi[this.i] = "F: TERRIBLE TRY";
- this.i = this.i + 1;
- this.giudizi[this.i] = "E: BAD EFFORT";
- this.i = this.i + 1;
- this.giudizi[this.i] = "D: POOR PERFORMANCE";
- this.i = this.i + 1;
- this.giudizi[this.i] = "C-:NOT VERY IMPRESSIVE";
- this.i = this.i + 1;
- this.giudizi[this.i] = "C: SATISFACTORY";
- this.i = this.i + 1;
- this.giudizi[this.i] = "C+: NOT BAD";
- this.i = this.i + 1;
- this.giudizi[this.i] = "B-: QUITE GOOD";
- this.i = this.i + 1;
- this.giudizi[this.i] = "B: NICE ROUND!";
- this.i = this.i + 1;
- this.giudizi[this.i] = "B+: GREAT JOB! ";
- this.i = this.i + 1;
- this.giudizi[this.i] = "A-:SERIOUSLY IMPRESSIVE!";
- this.i = this.i + 1;
- this.giudizi[this.i] = "A: STUNNING REFLEXES!";
- this.i = this.i + 1;
- this.giudizi[this.i] = "A+: YOU\'RE THE MAN!";
- this.maxgiudizio = this.i;
- this.scrittefinealpha = 0;
- this.olddeltatime = getTimer();
- this.musicmc = _root.createEmptyMovieClip("musicmc",245);
- this.ballsoundmc = _root.createEmptyMovieClip("ballsoundmc",246);
- this.ballsound = new Sound(this.ballsoundmc);
- this.ballsound.attachSound("ball.mp3");
- this.ballsound.setVolume(250);
- this.bumpersoundmc = _root.createEmptyMovieClip("bumpersoundmc",247);
- this.bumpersound = new Sound(this.bumpersoundmc);
- this.bumpersound.attachSound("bumper.mp3");
- this.bumpersound.setVolume(800);
- this.musicsound = new Sound(this.musicmc);
- this.musicsound.attachSound("112.mp3");
- this.mymusicvol = 100;
- this.musicsound.setVolume(this.mymusicvol);
- this.stoppingsound = false;
- if(this.soundson and startsound)
- {
- this.musicsound.start(0,150);
- }
- this.basecolortr = new flash.geom.ColorTransform(1,1,1,1,0,0,0,0);
- this.mycolortr = new flash.geom.ColorTransform(1,1,1,1,0,51,51,0);
- this.lastedtime = 0;
- this.gamephase = 0;
- this.myformat = new TextFormat();
- this.myformat.font = "verdana11";
- this.myformat.size = 13;
- this.myformat.bold = false;
- this.gametime = 0;
- this.gravity = 0;
- this.currentballs = 0;
- Mouse.hide();
- this.mymouse = _root.attachMovie("ball4mc","mymouse",100);
- this.mymouse.cacheAsBitmap = true;
- this.mymouse.r = 12;
- this.mymouse.x = 0;
- this.mymouse.y = 0;
- this.mymouse._x = -100;
- this.mymouse._y = -100;
- this.mymouse.xv = 0;
- this.mymouse.yv = 0;
- this.mymouse.mass = 1;
- this.mymouse.actualmass = 1;
- this.mymouse.hit = false;
- this.mymouse.xshift = 0;
- this.mymouse.yshift = 0;
- this.mymouse.spawning = true;
- this.mymouse.spawntime = this.maxspawntime;
- this.mymouse._alpha = 0;
- this.mymouse.colortr = new flash.geom.ColorTransform(0.2,0.2,0.9,1,0,0,25.5,0);
- this.mymouse.transform.colorTransform = this.mymouse.colortr;
- var _loc4_ = new flash.filters.DropShadowFilter(2,135,0,1,4,4,0.7,1,false,false,false);
- var _loc3_ = this.mymouse.filters;
- _loc3_.push(_loc4_);
- this.mymouse.filters = _loc3_;
- this.volumer = _root.attachMovie("volumermc","volumer",152);
- this.volumer.onRelease = function()
- {
- _root.game.soundson = !_root.game.soundson;
- if(_root.game.soundson)
- {
- _root.game.musicsound.start(0,150);
- this.gotoAndStop(1);
- }
- if(!_root.game.soundson)
- {
- _root.game.musicsound.stop();
- this.gotoAndStop(2);
- }
- };
- this.volumer._xscale = 16;
- this.volumer._yscale = 16;
- this.volumer._x = 229;
- this.volumer._y = 410;
- _loc3_ = this.volumer.filters;
- _loc3_.push(_loc4_);
- this.volumer.filters = _loc3_;
- if(this.soundson)
- {
- this.volumer.gotoAndStop(1);
- }
- if(!this.soundson)
- {
- this.volumer.gotoAndStop(2);
- }
- this.volumer._visible = false;
- this.scritte = new Array();
- this.i = 0;
- while(this.i < 8)
- {
- if(this.i <= 4 or this.i >= 7)
- {
- this.scritte[this.i] = _root.createEmptyMovieClip("scritte" + this.i,11100 + this.i);
- }
- else
- {
- this.scritte[this.i] = _root.createEmptyMovieClip("scritte" + this.i,this.i);
- }
- this.scritte[this.i].createTextField("scritta",0,0,0,0,0);
- this.scritte[this.i].scritta.textColor = 0;
- this.scritte[this.i].scritta.setNewTextFormat(this.myformat);
- this.scritte[this.i]._xscale = 100;
- this.scritte[this.i]._yscale = 100;
- this.scritte[this.i].scritta.autoSize = true;
- this.scritte[this.i].scritta.selectable = false;
- this.scritte[this.i]._visible = false;
- _loc3_ = this.scritte[this.i].filters;
- _loc3_.push(_loc4_);
- this.scritte[this.i].filters = _loc3_;
- this.scritte[this.i].scritta.embedFonts = true;
- this.i = this.i + 1;
- }
- this.scritte[5].scritta.text = "3 BALLS";
- this.scritte[5].stoptime = 0;
- this.scritte[5]._xscale = 120;
- this.scritte[5]._xscale = 120;
- this.scritte[5]._x = this.screenw / 2 - this.scritte[5]._width / 2;
- this.scritte[5]._y = 190;
- this.scritte[5].phase = 0;
- this.scritte[1].onRelease = function()
- {
- _root.game.gamephase = 2;
- Mouse.hide();
- };
- this.scritte[2].onRelease = function()
- {
- _root.game.gamephase = 3;
- };
- this.scritte[3].onRelease = function()
- {
- getUrl("http://www.ragdollsoft.com", "blank");
- };
- this.balls = new Array();
- this.i = 0;
- while(this.i < this.maxballs)
- {
- this.balls[this.i] = _root.attachMovie("ball4mc","ball" + this.i,this.i + 10);
- this.balls[this.i].mass = 1;
- this.balls[this.i].actualmass = 1;
- this.balls[this.i].r = 12;
- this.balls[this.i].x = Math.random() * (this.screenw - 2 * this.balls[this.i].r) + this.balls[this.i].r;
- this.balls[this.i].y = Math.random() * (this.screenh - 2 * this.balls[this.i].r) + this.balls[this.i].r;
- this.balls[this.i].colored = false;
- this.balls[this.i].oldx = this.balls[this.i].x;
- this.balls[this.i].oldy = this.balls[this.i].y;
- this.balls[this.i].xv = (Math.random() - 0.5) * 10 * 1.5;
- this.balls[this.i].yv = (Math.random() - 0.5) * 10 * 1.5;
- this.balls[this.i].angle = Math.random() * 3.141592653589793 * 2;
- this.balls[this.i].xv = Math.sin(this.balls[this.i].angle) * 6.5;
- this.balls[this.i].yv = Math.cos(this.balls[this.i].angle) * 6.5;
- this.balls[this.i].xshift = 0;
- this.balls[this.i].yshift = 0;
- this.balls[this.i]._visible = false;
- this.balls[this.i].cacheAsBitmap = true;
- this.balls[this.i].spawning = true;
- this.balls[this.i].spawntime = this.maxspawntime;
- this.balls[this.i].colortr = new flash.geom.ColorTransform(0.9,0.2,0.2,1,25.5,0,0,0);
- this.balls[this.i].transform.colorTransform = this.balls[this.i].colortr;
- _loc3_ = this.balls[this.i].filters;
- _loc3_.push(_loc4_);
- this.balls[this.i].filters = _loc3_;
- this.i = this.i + 1;
- }
- this.balls[0].colored = true;
- this.i = 0;
- while(this.i < this.currentballs)
- {
- this.balls[this.i]._visible = true;
- this.i = this.i + 1;
- }
- }
- function mainloop()
- {
- this.deltat = getTimer() - this.olddeltatime;
- this.deltamult = Math.min(this.deltat,40) / 28.571428571428573;
- this.olddeltatime = getTimer();
- var _loc3_ = undefined;
- var _loc4_ = undefined;
- this.fpstime += 1;
- if(!this.continousmusic and this.stoppingsound)
- {
- this.mymusicvol -= 1 * this.deltamult;
- this.musicsound.setVolume(this.mymusicvol);
- if(this.mymusicvol < 0)
- {
- this.musicsound.stop();
- this.stoppingsound = false;
- }
- }
- this.handlescritta();
- if(this.gamephase == 0)
- {
- if(!this.mymouse.hit)
- {
- this.lastedtime += 1 * this.deltamult;
- }
- if(getTimer() - this.oldmillisecs > 1000)
- {
- this.fpstime = 0;
- this.oldmillisecs = getTimer();
- }
- if(!this.mymouse.hit and !this.mymouse.spawning)
- {
- if(this.currentballs < this.realmaxballs)
- {
- this.gametime += 1 * this.deltamult;
- }
- if(this.gametime > 35 * (this.currentballs - 1) * 7)
- {
- this.gametime = 0;
- this.currentballs += 1;
- this.balls[this.currentballs - 1]._visible = true;
- this.scritte[5].scritta.text = this.currentballs + " BALLS";
- this.scritte[5].phase = 1;
- this.scritte[5]._alpha = 0;
- this.scritte[5]._visible = true;
- this.scritte[5].stoptime = 0;
- this.scritte[6].scritta.text = this.commenti[this.currentballs];
- this.scritte[6]._alpha = 0;
- this.scritte[6]._visible = true;
- this.scritte[6]._x = this.screenw / 2 - this.scritte[6]._width / 2;
- this.scritte[6]._y = 220;
- }
- }
- if(this.mymouse.spawning)
- {
- this.mymouse._alpha = (this.maxspawntime - this.mymouse.spawntime) / this.maxspawntime * 100;
- this.mymouse.spawntime -= 1 * this.deltamult;
- if(this.mymouse.spawntime < 0)
- {
- this.mymouse.spawning = false;
- this.mymouse._alpha = 100;
- this.currentballs = 3;
- this.scritte[5].scritta.text = this.currentballs + " BALLS";
- this.scritte[5].phase = 1;
- this.scritte[5]._alpha = 0;
- this.scritte[5]._visible = true;
- this.scritte[5].stoptime = 0;
- this.scritte[6].scritta.text = this.commenti[this.currentballs];
- this.scritte[6]._alpha = 0;
- this.scritte[6]._visible = true;
- this.scritte[6]._x = this.screenw / 2 - this.scritte[6]._width / 2;
- this.scritte[6]._y = 220;
- this.gametime = 0;
- _loc3_ = 0;
- while(_loc3_ < 3)
- {
- this.balls[_loc3_]._visible = true;
- _loc3_ = _loc3_ + 1;
- }
- }
- }
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- if(this.balls[_loc3_].spawning)
- {
- this.balls[_loc3_]._alpha = (this.maxspawntime - this.balls[_loc3_].spawntime) / this.maxspawntime * 100;
- this.balls[_loc3_].spawntime -= 1 * this.deltamult;
- if(this.balls[_loc3_].spawntime < 0)
- {
- this.balls[_loc3_].spawning = false;
- this.balls[_loc3_]._alpha = 100;
- }
- }
- _loc3_ = _loc3_ + 1;
- }
- if(this.mymouse.hit)
- {
- this.mymouse.yv += this.gravity * this.deltamult;
- this.mymouse.x += this.mymouse.xv * this.deltamult;
- this.mymouse.y += this.mymouse.yv * this.deltamult;
- }
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- if(!this.balls[_loc3_].spawning)
- {
- this.balls[_loc3_].yv += this.gravity * this.deltamult;
- this.balls[_loc3_].x += this.balls[_loc3_].xv * this.deltamult;
- this.balls[_loc3_].y += this.balls[_loc3_].yv * this.deltamult;
- }
- _loc3_ = _loc3_ + 1;
- }
- this.mymouse.xshift = 0;
- this.mymouse.yshift = 0;
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- this.balls[_loc3_].xshift = 0;
- this.balls[_loc3_].yshift = 0;
- _loc3_ = _loc3_ + 1;
- }
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- _loc4_ = _loc3_ + 1;
- while(_loc4_ < this.currentballs)
- {
- if((this.balls[_loc3_].x - this.balls[_loc4_].x) * (this.balls[_loc3_].x - this.balls[_loc4_].x) + (this.balls[_loc3_].y - this.balls[_loc4_].y) * (this.balls[_loc3_].y - this.balls[_loc4_].y) < (this.balls[_loc3_].r + this.balls[_loc4_].r) * (this.balls[_loc3_].r + this.balls[_loc4_].r) and !this.balls[_loc3_].spawning and !this.balls[_loc4_].spawning)
- {
- this.collision(this.balls[_loc3_],this.balls[_loc4_]);
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = 0;
- while(_loc4_ < this.currentballs)
- {
- if(!this.balls[_loc4_].spawning)
- {
- if((this.mymouse.x - this.balls[_loc4_].x) * (this.mymouse.x - this.balls[_loc4_].x) + (this.mymouse.y - this.balls[_loc4_].y) * (this.mymouse.y - this.balls[_loc4_].y) < (this.mymouse.r + this.balls[_loc4_].r) * (this.mymouse.r + this.balls[_loc4_].r))
- {
- this.collision(this.mymouse,this.balls[_loc4_]);
- this.mymouse.hit = true;
- this.gravity = this.maxgravity;
- if(!this.continousmusic)
- {
- this.stoppingsound = true;
- }
- }
- }
- _loc4_ = _loc4_ + 1;
- }
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- this.balls[_loc3_].x += this.balls[_loc3_].xshift;
- this.balls[_loc3_].y += this.balls[_loc3_].yshift;
- _loc3_ = _loc3_ + 1;
- }
- this.mymouse.x += this.mymouse.xshift;
- this.mymouse.y += this.mymouse.yshift;
- if(!this.mymouse.hit)
- {
- this.mymouse.x = _root._xmouse;
- this.mymouse.y = _root._ymouse;
- this.mymouse.xv = 0;
- this.mymouse.yv = 0;
- }
- this.bordercollision();
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- this.balls[_loc3_]._x = this.balls[_loc3_].x;
- this.balls[_loc3_]._y = this.balls[_loc3_].y;
- _loc3_ = _loc3_ + 1;
- }
- this.mymouse._x = this.mymouse.x;
- this.mymouse._y = this.mymouse.y;
- }
- if(this.mymouse.hit and this.gamephase == 0)
- {
- var _loc6_ = 1;
- _loc3_ = 0;
- while(_loc3_ < this.currentballs)
- {
- if(this.balls[_loc3_].y < this.screenh + 100)
- {
- _loc6_ = 0;
- }
- _loc3_ = _loc3_ + 1;
- }
- if(this.mymouse.y < this.screenh + 100)
- {
- _loc6_ = 0;
- }
- if(_loc6_)
- {
- Mouse.show();
- this.gamephase = 1;
- var _loc5_ = 1;
- var _loc9_ = 1;
- var _loc7_ = 40;
- var _loc8_ = 30;
- this.scritte[4].scritta.text = "YOU REACHED " + this.currentballs + " BALLS";
- this.scritte[4]._xscale = _loc9_ * 100;
- this.scritte[4]._yscale = _loc9_ * 100;
- this.scritte[4]._x = this.screenw / 2 - this.scritte[4]._width / 2;
- this.scritte[4]._y = 70 + _loc8_;
- this.scritte[4]._visible = true;
- this.scritte[0].scritta.text = "YOU LASTED " + Math.floor(this.lastedtime / 35) + " SECONDS";
- this.scritte[0]._xscale = _loc5_ * 100;
- this.scritte[0]._yscale = _loc5_ * 100;
- this.scritte[0]._x = this.screenw / 2 - this.scritte[0]._width / 2;
- this.scritte[0]._y = 110 + _loc8_;
- this.scritte[0]._visible = true;
- this.scritte[7].scritta.text = "GRADE " + this.giudizi[Math.min(Math.floor(this.lastedtime / 35 / 15),this.maxgiudizio)];
- this.scritte[7]._xscale = _loc5_ * 100;
- this.scritte[7]._yscale = _loc5_ * 100;
- this.scritte[7]._x = this.screenw / 2 - this.scritte[7]._width / 2;
- this.scritte[7]._y = 150 + _loc8_;
- this.scritte[7]._visible = true;
- this.scritte[1].scritta.text = "PLAY AGAIN";
- this.scritte[1]._xscale = 100 * _loc5_;
- this.scritte[1]._yscale = 100 * _loc5_;
- this.scritte[1]._x = this.screenw / 2 - this.scritte[1]._width / 2;
- this.scritte[1]._y = 200 + _loc7_;
- this.scritte[1]._visible = true;
- this.scritte[2].scritta.text = "BACK TO MENU";
- this.scritte[2]._xscale = 100 * _loc5_;
- this.scritte[2]._yscale = 100 * _loc5_;
- this.scritte[2]._x = this.screenw / 2 - this.scritte[2]._width / 2;
- this.scritte[2]._y = 240 + _loc7_;
- this.scritte[2]._visible = true;
- this.scritte[3].scritta.text = "MORE GAMES BY ME";
- this.scritte[3]._xscale = 100 * _loc5_;
- this.scritte[3]._yscale = 100 * _loc5_;
- this.scritte[3]._x = this.screenw / 2 - this.scritte[3]._width / 2;
- this.scritte[3]._y = 280 + _loc7_;
- this.scritte[3]._visible = true;
- this.mymouse._alpha = 0;
- this.volumer._visible = true;
- }
- }
- if(this.gamephase == 1)
- {
- if(this.scrittefinealpha < 100)
- {
- this.scrittefinealpha += 3 * this.deltamult;
- }
- }
- if(this.gamephase == 2)
- {
- this.scrittefinealpha -= 3 * this.deltamult;
- if(this.scrittefinealpha <= 0)
- {
- if(!_root.game.continousmusic)
- {
- _root.game.musicsound.stop();
- }
- _root.game.init(!_root.game.continousmusic);
- }
- }
- if(this.gamephase == 3)
- {
- this.scrittefinealpha -= 3 * this.deltamult;
- if(this.scrittefinealpha <= 0)
- {
- _root.game.musicsound.stop();
- _root.gotoAndPlay("mainmenu");
- }
- }
- if(this.gamephase > 0)
- {
- _loc3_ = 0;
- while(_loc3_ < 5)
- {
- this.scritte[_loc3_]._alpha = this.scrittefinealpha;
- _loc3_ = _loc3_ + 1;
- }
- _loc3_ = 7;
- while(_loc3_ < 8)
- {
- this.scritte[_loc3_]._alpha = this.scrittefinealpha;
- _loc3_ = _loc3_ + 1;
- }
- this.volumer._alpha = this.scrittefinealpha;
- }
- }
- function handlescritta()
- {
- if(this.scritte[5].phase == 1)
- {
- this.scritte[5]._alpha += 2 * this.deltamult;
- this.scritte[6]._alpha = this.scritte[5]._alpha;
- if(this.scritte[5]._alpha > 100)
- {
- this.scritte[5].phase = 2;
- }
- }
- if(this.scritte[5].phase == 2)
- {
- this.scritte[5].stoptime += 1 * this.deltamult;
- if(this.scritte[5].stoptime > 10)
- {
- this.scritte[5].phase = 3;
- }
- }
- if(this.scritte[5].phase == 3)
- {
- this.scritte[5]._alpha -= 2 * this.deltamult;
- this.scritte[6]._alpha = this.scritte[5]._alpha;
- if(this.scritte[5]._alpha <= 0)
- {
- this.scritte[6]._visible = false;
- this.scritte[5]._visible = false;
- this.scritte[5].phase = 0;
- }
- }
- }
- function bordercollision()
- {
- var _loc2_ = 0.01;
- var _loc3_ = 1;
- var _loc4_ = 40 * this.mymusicvol / 100;
- this.i = 0;
- while(this.i < this.currentballs)
- {
- if(this.balls[this.i].x < 0 + this.balls[this.i].r)
- {
- this.bumpersound.setVolume(Math.abs(this.balls[this.i].xv) * _loc4_);
- if(this.soundson)
- {
- this.bumpersound.start();
- }
- this.balls[this.i].x = 0 + _loc2_ + this.balls[this.i].r;
- this.balls[this.i].xv = (- this.balls[this.i].xv) * _loc3_;
- }
- if(this.balls[this.i].x > this.screenw - this.balls[this.i].r)
- {
- this.bumpersound.setVolume(Math.abs(this.balls[this.i].xv) * _loc4_);
- if(this.soundson)
- {
- this.bumpersound.start();
- }
- this.balls[this.i].x = this.screenw - _loc2_ - this.balls[this.i].r;
- this.balls[this.i].xv = (- this.balls[this.i].xv) * _loc3_;
- }
- if(this.balls[this.i].y > this.screenh - this.balls[this.i].r and !this.mymouse.hit)
- {
- this.bumpersound.setVolume(Math.abs(this.balls[this.i].yv) * _loc4_);
- if(this.soundson)
- {
- this.bumpersound.start();
- }
- this.balls[this.i].y = this.screenh - _loc2_ - this.balls[this.i].r;
- this.balls[this.i].yv = (- this.balls[this.i].yv) * _loc3_;
- }
- if(this.balls[this.i].y < 0 + this.balls[this.i].r)
- {
- this.bumpersound.setVolume(Math.abs(this.balls[this.i].yv) * _loc4_);
- if(this.soundson)
- {
- this.bumpersound.start();
- }
- this.balls[this.i].y = 0 + _loc2_ + this.balls[this.i].r;
- this.balls[this.i].yv = (- this.balls[this.i].yv) * _loc3_;
- }
- this.i = this.i + 1;
- }
- if(this.mymouse.x < 0 + this.mymouse.r)
- {
- this.mymouse.x = 0 + _loc2_ + this.mymouse.r;
- this.mymouse.xv = (- this.mymouse.xv) * _loc3_;
- }
- if(this.mymouse.x > this.screenw - this.mymouse.r)
- {
- this.mymouse.x = this.screenw - _loc2_ - this.mymouse.r;
- this.mymouse.xv = (- this.mymouse.xv) * _loc3_;
- }
- if(this.mymouse.y > this.screenh - this.mymouse.r and !this.mymouse.hit)
- {
- this.mymouse.y = this.screenh - _loc2_ - this.mymouse.r;
- this.mymouse.yv = (- this.mymouse.yv) * _loc3_;
- }
- if(this.mymouse.y < 0 + this.mymouse.r)
- {
- this.mymouse.y = 0 + _loc2_ + this.mymouse.r;
- this.mymouse.yv = (- this.mymouse.yv) * _loc3_;
- }
- }
- function collision(ball1, ball2)
- {
- var _loc5_ = 1.0000000000000001e-7;
- var _loc15_ = 3000;
- var _loc14_ = 50 * this.mymusicvol / 100;
- var _loc7_ = ball2.x - ball1.x;
- var _loc6_ = ball2.y - ball1.y;
- var _loc4_ = Math.sqrt(_loc7_ * _loc7_ + _loc6_ * _loc6_);
- var _loc9_ = ball1.r + ball2.r;
- if(_loc4_ < _loc9_)
- {
- var _loc13_ = ball2.xv - ball1.xv;
- var _loc12_ = ball2.yv - ball1.yv;
- if(Math.abs(_loc4_) < _loc5_)
- {
- _loc4_ = _loc5_;
- }
- if(Math.abs(_loc7_) < _loc5_)
- {
- _loc7_ = _loc5_;
- }
- if(Math.abs(_loc6_) < _loc5_)
- {
- _loc6_ = _loc5_;
- }
- var _loc8_ = _loc6_ / _loc7_;
- if(Math.abs(_loc8_) < _loc5_)
- {
- _loc8_ = _loc5_;
- }
- var _loc10_ = -1 * (_loc12_ + 1 / _loc8_ * _loc13_) / (_loc8_ + 1 / _loc8_);
- var _loc11_ = _loc10_ * _loc8_;
- ball1.xshift -= (_loc9_ + 0.01 - _loc4_) * _loc7_ / _loc4_ * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
- ball1.yshift -= (_loc9_ + 0.01 - _loc4_) * _loc6_ / _loc4_ * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
- ball2.xshift += (_loc9_ + 0.01 - _loc4_) * _loc7_ / _loc4_ * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
- ball2.yshift += (_loc9_ + 0.01 - _loc4_) * _loc6_ / _loc4_ * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
- ball1.xv -= _loc10_ * 2 * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
- ball1.yv -= _loc11_ * 2 * ball1.actualmass / (ball1.actualmass + ball2.actualmass);
- ball2.xv += _loc10_ * 2 * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
- ball2.yv += _loc11_ * 2 * ball2.actualmass / (ball1.actualmass + ball2.actualmass);
- this.ballsound.setVolume(Math.sqrt(_loc10_ * _loc10_ + _loc11_ * _loc11_) * _loc14_);
- if(this.soundson)
- {
- this.ballsound.start();
- }
- }
- }
- function repulse(ball1, ball2)
- {
- var _loc4_ = 3000;
- var _loc3_ = ball2.x - ball1.x;
- var _loc2_ = ball2.y - ball1.y;
- var _loc1_ = Math.sqrt(_loc3_ * _loc3_ + _loc2_ * _loc2_);
- ball1.xshift += (- _loc4_) * _loc3_ / _loc1_ / _loc1_ / _loc1_;
- ball2.xshift += _loc4_ * _loc3_ / _loc1_ / _loc1_ / _loc1_;
- ball1.yshift += (- _loc4_) * _loc2_ / _loc1_ / _loc1_ / _loc1_;
- ball2.yshift += _loc4_ * _loc2_ / _loc1_ / _loc1_ / _loc1_;
- }
- }
-