home *** CD-ROM | disk | FTP | other *** search
- package game
- {
- import flash.events.Event;
- import flash.events.TimerEvent;
-
- public class Jumper extends GameObject
- {
-
- public static var rightJumpImageClass:Class = Jumper_rightJumpImageClass;
-
- public static var leftJumpImageClass:Class = Jumper_leftJumpImageClass;
-
- public static var jumpImageClass:Class = Jumper_jumpImageClass;
-
- public static var imageClass:Class = Jumper_imageClass;
-
-
- private var theGame:Game;
-
- public var overGoingPhase:int = 0;
-
- public function Jumper(theGame:Game, x:int, y:int, w:int, h:int)
- {
- super(x,y,w,h);
- this.theGame = theGame;
- ay = 0.18;
- Game.timer.addEventListener("timer",move);
- }
-
- override public function move(event:TimerEvent) : void
- {
- vx += ax;
- vy += ay;
- x += vx;
- y += vy;
- theGame.checkHit();
- if(x < 0)
- {
- x = 0;
- }
- if(x + w > 640)
- {
- x = 640 - w;
- }
- if(overGoingPhase == 0)
- {
- if(y + h / 2 < 230 && vy < 0)
- {
- if(x + w / 2 < 330)
- {
- overGoingPhase = 1;
- }
- if(x + w / 2 > 330)
- {
- overGoingPhase = 2;
- }
- }
- }
- if(overGoingPhase != 0 && overGoingPhase != 3)
- {
- if(y + h / 2 > 240 && y + h / 2 < 250 && vy > 0)
- {
- if(overGoingPhase == 1 && x + w / 2 > 330 || overGoingPhase == 2 && x + w / 2 < 330)
- {
- overGoingPhase = 4;
- theGame.wentOver();
- }
- }
- }
- dispatchEvent(new Event("objectChanged"));
- }
-
- public function jump() : void
- {
- if(Game.powerup == 1)
- {
- vy = -9;
- }
- else
- {
- vy = -7.5;
- }
- if(vx < 0)
- {
- dispatchEvent(new GraphicsChangedEvent("graphicsChanged",leftJumpImageClass,32));
- }
- else if(vx > 0)
- {
- dispatchEvent(new GraphicsChangedEvent("graphicsChanged",rightJumpImageClass,32));
- }
- else
- {
- dispatchEvent(new GraphicsChangedEvent("graphicsChanged",jumpImageClass,32));
- }
- }
- }
- }
-