home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / Jumper.swf / scripts / game / Bouncer.as < prev    next >
Encoding:
Text File  |  2008-09-05  |  1.5 KB  |  74 lines

  1. package game
  2. {
  3.    import flash.events.TimerEvent;
  4.    
  5.    public class Bouncer extends GameObject
  6.    {
  7.       
  8.       public static var maxSpeed:Number = 4;
  9.       
  10.       public static var speed:Number = 2;
  11.       
  12.       public static var width:Number = 50;
  13.       
  14.       public static var minWidth:Number = 10;
  15.       
  16.       public static var imageClass:Class = Bouncer_imageClass;
  17.        
  18.       
  19.       public function Bouncer(x:int = 0)
  20.       {
  21.          super(x,370,width,10);
  22.          var rand:Number = Math.random();
  23.          if(rand < 0.5)
  24.          {
  25.             x = -width;
  26.             vx = speed;
  27.          }
  28.          else
  29.          {
  30.             vx = speed * -1;
  31.             x = 640;
  32.          }
  33.          Game.timer.addEventListener("timer",move);
  34.       }
  35.       
  36.       public static function reduceWidth() : void
  37.       {
  38.          if(width > minWidth)
  39.          {
  40.             width -= 0.8;
  41.          }
  42.       }
  43.       
  44.       public static function reset() : void
  45.       {
  46.          speed = 1;
  47.          width = 50;
  48.       }
  49.       
  50.       public static function addSpeed() : void
  51.       {
  52.          if(speed < maxSpeed)
  53.          {
  54.             speed += 0.1;
  55.          }
  56.       }
  57.       
  58.       override public function move(event:TimerEvent) : void
  59.       {
  60.          if(y <= 370)
  61.          {
  62.             y = 370;
  63.             vy = 0;
  64.          }
  65.          else
  66.          {
  67.             vy -= 0.3;
  68.             y += vy;
  69.          }
  70.          super.move(event);
  71.       }
  72.    }
  73. }
  74.