home *** CD-ROM | disk | FTP | other *** search
- function go()
- {
- this.action = bounce;
- }
- function bounce()
- {
- accelerate();
- move();
- bouncercollide();
- munchcollide();
- bounds();
- checksplash();
- }
- function bounds()
- {
- if(_X + RIGHTFUDGE >= _root.RIGHTWALL)
- {
- _X = _X - (_X + RIGHTFUDGE - _root.RIGHTWALL);
- vx = - vx;
- }
- if(_X + LEFTFUDGE <= _root.LEFTWALL)
- {
- _X = _X + (_root.LEFTWALL - (_X + LEFTFUDGE));
- vx = - vx;
- }
- if(_Y + TOPFUDGE <= _root.CEILING)
- {
- _Y = _Y + (_root.CEILING - (_Y + TOPFUDGE));
- vy = 0;
- vx = 0;
- this.action = feather;
- }
- }
- function accelerate()
- {
- vyi = vy + a * dt;
- dy = (vy + vyi) * 0.5 * dt * speed_multiplier;
- if(Math.abs(dy) > MAXDIST)
- {
- dy = MAXDIST * (dy <= 0 ? -1 : 1);
- vyi = Math.abs(vyi) <= Math.abs(vy) ? vyi : vy;
- }
- if(vyi >= 0 && vy <= 0 && _currentframe != frame_fall)
- {
- this.gotoAndPlay(frame_startfall);
- }
- }
- function move()
- {
- _Y = _Y + dy;
- _X = _X + (vx * dt * speed_multiplier + (_root.bouncer._x - (_X + FOOTX + 5)) * _root.BINDI);
- vy = vyi;
- }
- function feather()
- {
- accelerate();
- if(dy > max_dy)
- {
- dy = max_dy;
- vyi = Math.abs(vyi) <= Math.abs(vy) ? vyi : vy;
- }
- move();
- bouncercollide();
- bounds();
- checksplash();
- }
- function bouncercollide()
- {
- if(_Y + FOOTY >= _root.BOUNCERZONE && vy > 0 && _root.bouncer.hitzone.hitTest(_X + FOOTX,_Y + FOOTY - TINA,true))
- {
- var _loc3_ = Math.max(-1,Math.min(1,3 * (_X + FOOTX + 5 - _root.bouncer._x) / _root.bouncer._width));
- vx = (- _loc3_) * side_fling;
- vy = (- vy) * (1 - Math.abs(_loc3_) * middlepower) * damping - bounce_amount;
- _root.bouncer.bounce();
- this.gotoAndPlay(this.frame_bounce);
- this.bouncecounter = 14;
- this.action = bouncer;
- }
- }
- function bouncer()
- {
- this.play();
- if(this.bouncecounter < 13 && this._currentframe >= this.frame_bouncebottom)
- {
- this.action = bounce;
- }
- else if(this.bouncecounter < 0)
- {
- this.action = bounce;
- }
- this.bouncecounter = this.bouncecounter - 1;
- }
- function powerup(p)
- {
- if(p < P_MULTIMUNCH)
- {
- return undefined;
- }
- this.ptime = PFRAMES;
- this.power = Math.max(this.power,p);
- _root.game.stopsound("s_synth");
- _root.game.stopsound("s_drumloop");
- _root.game.playsoundloop(this.power != P_MULTIMUNCH ? "s_synth" : "s_drumloop");
- }
- function munchcollide()
- {
- if(!_root.maze.hitTest(_X + MOUTHX,_Y + MOUTHY,false))
- {
- return false;
- }
- var _loc9_ = 0;
- while(_loc9_ < _root.maze.brickclipno)
- {
- var _loc5_ = _root.maze["brick" + _loc9_];
- if(_loc5_._alpha == 100 && !_loc5_.falling && _loc5_.hitTest(_X + MOUTHX,_Y + MOUTHY,false) && vy <= 0)
- {
- var _loc7_ = _loc5_.myi;
- var _loc6_ = _loc5_.myj;
- if(this.power == P_MULTIMUNCH)
- {
- var _loc8_ = undefined;
- var _loc4_ = -1;
- while(_loc4_ <= 1)
- {
- var _loc3_ = -1;
- while(_loc3_ <= 1)
- {
- if(_root.maze.hasbrick(_loc4_ + _loc7_,_loc3_ + _loc6_))
- {
- _loc8_ = _root.maze.brickat(_loc4_ + _loc7_,_loc3_ + _loc6_);
- _loc8_.eaten(this);
- }
- _loc3_ = _loc3_ + 1;
- }
- _loc4_ = _loc4_ + 1;
- }
- }
- else
- {
- _loc5_.eaten(this);
- }
- _root.game.playsound("s_chomp");
- _root.maze.hang();
- this.gotoAndPlay(this.frame_eat);
- this.munchcounter = 14;
- this.action = munch;
- if(this.power != P_ZIG)
- {
- vy = - vy;
- vx = 0;
- }
- break;
- }
- _loc9_ = _loc9_ + 1;
- }
- }
- function munch()
- {
- this.play();
- if(this.power == P_ZIG)
- {
- this.action = bounce;
- }
- if(this.munchcounter < 13 && this._currentframe >= this.frame_eatrelease)
- {
- this.action = feather;
- }
- else if(this.munchcounter < 0)
- {
- this.action = feather;
- }
- this.munchcounter = this.munchcounter - 1;
- }
- function jumpon()
- {
- _X = _root.jumpfrom._x - LEFTFUDGE;
- _Y = _root.jumpfrom._y;
- vx = 180;
- vy = -180;
- this.jumpontime = 0;
- this.action = jumpingon;
- }
- function jumpingon()
- {
- accelerate();
- move();
- if(vy > 0.5)
- {
- var _loc4_ = 23;
- var _loc3_ = this.jumpontime++ / _loc4_;
- this.jumpontime = Math.min(_loc4_,this.jumpontime);
- vx = (1 - _loc3_) * vx + _loc3_ * (invscaling * 0.1 * (_root.bouncer._x - (this._x + FOOTX + 5)));
- }
- bouncercollide();
- checksplash();
- }
- function jumpeasy()
- {
- this.jumpeasytime = 0;
- this.action = jumpingeasy;
- this.vy = 0;
- }
- function jumpingeasy()
- {
- accelerate();
- if(dy > max_dy)
- {
- dy = max_dy;
- vyi = vy;
- }
- move();
- var _loc3_ = 33;
- var _loc4_ = this.jumpeasytime++ / _loc3_;
- this.jumpeasytime = Math.min(_loc3_,this.jumpeasytime);
- vx = (1 - _loc4_) * this.vx + _loc4_ * (invscaling * 0.05 * (_root.bouncer._x - (this._x + FOOTX + 5)));
- bouncercollideeasy();
- checksplash();
- }
- function bouncercollideeasy()
- {
- if(_Y + FOOTY >= _root.BOUNCERZONE && vy > 0 && _root.bouncer.hitzone.hitTest(_X + FOOTX,_Y + FOOTY - TINA,true))
- {
- var _loc3_ = Math.max(-1,Math.min(1,3 * (_X + FOOTX + 5 - _root.bouncer._x) / _root.bouncer._width));
- vx = 0;
- vy = -222;
- _root.bouncer.bounce();
- this.gotoAndPlay(this.frame_bounce);
- this.bouncecounter = 14;
- this.action = bouncereasy;
- }
- }
- function bouncereasy()
- {
- this.play();
- if(this.bouncecounter < 13 && this._currentframe >= this.frame_bouncebottom)
- {
- this.action = jumpingeasy;
- }
- else if(this.bouncecounter < 0)
- {
- this.action = jumpingeasy;
- }
- this.bouncecounter = this.bouncecounter - 1;
- }
- function splash()
- {
- move();
- _root.game.playsound("s_splash");
- _root.game.fragglesplash(this);
- this.action = swimaway;
- }
- function swimaway()
- {
- this.removeMovieClip();
- }
- function checksplash()
- {
- if(_Y + BOTTOMFUDGE >= _root.bouncer._y + 20)
- {
- _Y = _root.bouncer._y + 20 - BOTTOMFUDGE;
- this.action = splash;
- }
- }
- function gameoverf()
- {
- _root.game.stopsound("s_synth");
- _root.game.stopsound("s_drumloop");
- this.action = fall;
- }
- function fall()
- {
- accelerate();
- move();
- bounds();
- checksplash();
- }
- frame_fall = 2;
- frame_bounce = 3;
- frame_bouncebottom = 6;
- frame_fly = 11;
- frame_eat = 12;
- frame_eatrelease = 18;
- frame_startfall = 23;
- speed_multiplier = 1.5;
- vx = 0.5 * this._height;
- vy = 0;
- a = 3.6 * _height;
- subframes = 2;
- dt = 1 / (20 * subframes);
- max_dy = 5 * this._height;
- damping = 0.9;
- middlepower = 0.8;
- bounce_amount = 1 * this._height;
- side_fling = 1.5 * this._width;
- w = _width / 2;
- h = _height / 2;
- TOPFUDGE = 10;
- BOTTOMFUDGE = _height - 5;
- LEFTFUDGE = 23;
- RIGHTFUDGE = 58;
- CENTERFUDGE = 40;
- FOOTY = 80;
- FOOTX = w;
- TINA = 3;
- MOUTHY = 16;
- MOUTHX = 38;
- this.jumpon();
- P_NONE = _root.P_NONE;
- P_HI = _root.P_HI;
- P_MULTIMUNCH = _root.P_MULTIMUNCH;
- P_ZIG = _root.P_ZIG;
- MAXDIST = _root.halfbrick * 4;
- invscaling = 1 / (speed_multiplier * dt);
- this.ptime = 0;
- this.power = 0;
- PFRAMES = 400;
- this.onEnterFrame = function()
- {
- this.action();
- this.action();
- if(this.ptime > 0)
- {
- this.ptime = this.ptime - 1;
- }
- else
- {
- _root.game.stopsound("s_synth");
- _root.game.stopsound("s_drumloop");
- this.power = P_NONE;
- }
- if(this.breakstart)
- {
- this.jumpeasy();
- this.breakstart = false;
- }
- if(this.breakdone)
- {
- this.go();
- this.breakdone = false;
- }
- if(this.gameoverflag)
- {
- this.gameoverf();
- this.gameoverflag = false;
- }
- };
-