home *** CD-ROM | disk | FTP | other *** search
- package
- {
- import flash.display.*;
- import flash.events.*;
-
- [Embed(source="/_assets/assets.swf", symbol="Player")]
- public class Player extends Actor
- {
-
-
- internal var shot:Boolean;
-
- internal var speed:int;
-
- internal var health:int;
-
- internal var gun:Gun;
-
- public function Player()
- {
- super();
- init();
- }
-
- internal function init() : void
- {
- addEventListener(Event.ENTER_FRAME,update);
- speed = 7;
- gun = new Gun(3,25);
- health = 5;
- shot = false;
- }
-
- internal function die() : void
- {
- visible = false;
- (parent as MovieClip).restart();
- }
-
- internal function controls(param1:Array) : void
- {
- var _loc2_:int = 0;
- var _loc3_:int = 0;
- velx = 0;
- vely = 0;
- if(param1[38])
- {
- vely = speed * -1;
- }
- else if(param1[40])
- {
- vely = speed;
- }
- else if(param1[37])
- {
- velx = speed * -1;
- }
- else if(param1[39])
- {
- velx = speed;
- }
- _loc3_ = 0;
- _loc2_ = 0;
- if(param1[87])
- {
- _loc3_ = -1;
- }
- if(param1[83])
- {
- _loc3_ = 1;
- }
- if(param1[65])
- {
- _loc2_ = -1;
- }
- if(param1[68])
- {
- _loc2_ = 1;
- }
- if((_loc3_ != 0 || _loc2_ != 0) && shot == false)
- {
- gun.fire(x,y,_loc2_,_loc3_);
- shot = true;
- }
- if(!param1[87] && !param1[83] && !param1[65] && !param1[68])
- {
- shot = false;
- }
- }
-
- internal function update(param1:Event) : void
- {
- var _loc2_:int = 0;
- x += velx;
- y += vely;
- if(x < 0)
- {
- x = 0;
- }
- if(x > 720)
- {
- x = 720;
- }
- if(y < 0)
- {
- y = 0;
- }
- if(y > 480)
- {
- y = 480;
- }
- gun.update(param1);
- }
- }
- }
-