home *** CD-ROM | disk | FTP | other *** search
- function hitPlatforms()
- {
- var i;
- var y;
- var x;
- i = 0;
- while(i < _root.maxPlatforms)
- {
- platform = eval("_root.platform" + i);
- y = _Y + vertical;
- x = _X + horizontal;
- if(_Y < platform._y && y >= platform._y && platform.hitTest(x,platform._y) == true)
- {
- _Y = platform._y;
- falling = false;
- vertical = 0;
- return undefined;
- }
- i++;
- }
- platform = null;
- return undefined;
- }
- function render()
- {
- var x;
- var y;
- x = y = 0;
- if(Math.abs(horizontal) < Math.abs(x))
- {
- horizontal = x;
- }
- else
- {
- horizontal *= friction;
- if(Math.abs(horizontal) < 1)
- {
- horizontal = 0;
- }
- }
- if(vertical == 0 && _root.hero.hitTest(_root.mushroom) && _root.hero._y == 285.25 || vertical == 0 && _root.hero.hitTest(_root.mushroom2) && _root.hero._y == 285.25 || vertical == 0 && _root.hero.hitTest(_root.mushroom3) && _root.hero._y == 285.25)
- {
- _root.hero._y -= 100;
- vertical = vforce * -1;
- horizontal += platform.velocity;
- platform = null;
- rising = true;
- if(_root.direction == 0)
- {
- gotoAndStop(4);
- }
- else
- {
- gotoAndStop(5);
- }
- }
- if(vertical == 0 && Key.isDown(38) == true and _root.alive == "yes" || vertical == 0 && Key.isDown(32) == true and _root.alive == "yes")
- {
- vertical = vforce * -1;
- horizontal += platform.velocity;
- platform = null;
- rising = true;
- if(_root.direction == 0)
- {
- gotoAndStop(4);
- }
- else
- {
- gotoAndStop(5);
- }
- jump.start();
- jump.setVolume(100);
- }
- if(rising == true)
- {
- vertical *= gravity;
- if(Math.abs(vertical) < 1)
- {
- vertical = Math.abs(vertical);
- falling = true;
- rising = false;
- if(_root.direction == 0)
- {
- gotoAndStop(3);
- }
- else
- {
- gotoAndStop(2);
- }
- }
- }
- if(falling == true)
- {
- vertical += accel;
- hitPlatforms();
- }
- lastX = _X;
- lastY = _Y;
- _Y = _Y + vertical;
- _X = _X + horizontal + platform.velocity;
- if(platform != null && platform.hitTest(_X,platform._y,true) == false)
- {
- vertical = 2;
- falling = true;
- }
- }
- vforce = 120;
- hforce = 10;
- horizontal = 0;
- vertical = 5;
- friction = 0.8;
- gravity = 0.5;
- accel = 1.5;
- rising = false;
- falling = true;
- lastX = _X;
- lastY = _Y;
- platform = null;
- jump = new sound();
- jump.attachSound("jump");
- stop();
-