home *** CD-ROM | disk | FTP | other *** search
- package game
- {
- import flash.events.TimerEvent;
-
- public class Bouncer extends GameObject
- {
-
- public static var maxSpeed:Number = 4;
-
- public static var speed:Number = 2;
-
- public static var width:Number = 50;
-
- public static var minWidth:Number = 10;
-
- public static var imageClass:Class = Bouncer_imageClass;
-
-
- public function Bouncer(x:int = 0)
- {
- super(x,370,width,10);
- var rand:Number = Math.random();
- if(rand < 0.5)
- {
- x = -width;
- vx = speed;
- }
- else
- {
- vx = speed * -1;
- x = 640;
- }
- Game.timer.addEventListener("timer",move);
- }
-
- public static function reduceWidth() : void
- {
- if(width > minWidth)
- {
- width -= 0.8;
- }
- }
-
- public static function reset() : void
- {
- speed = 1;
- width = 50;
- }
-
- public static function addSpeed() : void
- {
- if(speed < maxSpeed)
- {
- speed += 0.1;
- }
- }
-
- override public function move(event:TimerEvent) : void
- {
- if(y <= 370)
- {
- y = 370;
- vy = 0;
- }
- else
- {
- vy -= 0.3;
- y += vy;
- }
- super.move(event);
- }
- }
- }
-