home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / flameout.swf / scripts / __Packages / HumanPlayerController.as < prev    next >
Encoding:
Text File  |  2006-06-13  |  1.9 KB  |  79 lines

  1. class HumanPlayerController extends PlayerController
  2. {
  3.    var m_bFireKeyDown;
  4.    var m_kPlayer;
  5.    function HumanPlayerController()
  6.    {
  7.       super();
  8.    }
  9.    function init()
  10.    {
  11.       super.init();
  12.       this.m_bFireKeyDown = false;
  13.       Key.addListener(this);
  14.       Mouse.addListener(this);
  15.    }
  16.    function onStartGame()
  17.    {
  18.    }
  19.    function onStartRound()
  20.    {
  21.       this.m_bFireKeyDown = false;
  22.       this.m_kPlayer.setAngularVelocity(0);
  23.    }
  24.    function onEndRound()
  25.    {
  26.    }
  27.    function onMouseMove()
  28.    {
  29.       if(ApplicationState(_global.getApplicationState()).isPaused())
  30.       {
  31.          return undefined;
  32.       }
  33.       this.m_kPlayer._rotation = Math.atan2(this.m_kPlayer._parent._ymouse - this.m_kPlayer._y,this.m_kPlayer._parent._xmouse - this.m_kPlayer._x) / 3.141592653589793 * 180;
  34.    }
  35.    function onMouseDown()
  36.    {
  37.       if(ApplicationState(_global.getApplicationState()).isPaused())
  38.       {
  39.          return undefined;
  40.       }
  41.       if(_global.g_kApplication.m_kGui.m_kPlayGui.m_kMuteButtonHolder.hitTest(_root._xmouse,_root._ymouse,false))
  42.       {
  43.          return undefined;
  44.       }
  45.       this.m_kPlayer.onRequestShootFireBeam();
  46.    }
  47.    function onKeyUp()
  48.    {
  49.       if(!Key.isDown(32))
  50.       {
  51.          this.m_bFireKeyDown = false;
  52.       }
  53.    }
  54.    function update(fDeltaSecs)
  55.    {
  56.       if(ApplicationState(_global.getApplicationState()).isPaused())
  57.       {
  58.          return undefined;
  59.       }
  60.       if(Key.isDown(37))
  61.       {
  62.          this.m_kPlayer.onRequestTurnLeft();
  63.       }
  64.       else if(Key.isDown(39))
  65.       {
  66.          this.m_kPlayer.onRequestTurnRight();
  67.       }
  68.       else
  69.       {
  70.          this.m_kPlayer.onRequestStop();
  71.       }
  72.       if(!this.m_bFireKeyDown && Key.isDown(32))
  73.       {
  74.          this.m_bFireKeyDown = true;
  75.          this.m_kPlayer.onRequestShootFireBeam();
  76.       }
  77.    }
  78. }
  79.