home *** CD-ROM | disk | FTP | other *** search
- class HumanPlayerController extends PlayerController
- {
- var m_bFireKeyDown;
- var m_kPlayer;
- function HumanPlayerController()
- {
- super();
- }
- function init()
- {
- super.init();
- this.m_bFireKeyDown = false;
- Key.addListener(this);
- Mouse.addListener(this);
- }
- function onStartGame()
- {
- }
- function onStartRound()
- {
- this.m_bFireKeyDown = false;
- this.m_kPlayer.setAngularVelocity(0);
- }
- function onEndRound()
- {
- }
- function onMouseMove()
- {
- if(ApplicationState(_global.getApplicationState()).isPaused())
- {
- return undefined;
- }
- 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;
- }
- function onMouseDown()
- {
- if(ApplicationState(_global.getApplicationState()).isPaused())
- {
- return undefined;
- }
- if(_global.g_kApplication.m_kGui.m_kPlayGui.m_kMuteButtonHolder.hitTest(_root._xmouse,_root._ymouse,false))
- {
- return undefined;
- }
- this.m_kPlayer.onRequestShootFireBeam();
- }
- function onKeyUp()
- {
- if(!Key.isDown(32))
- {
- this.m_bFireKeyDown = false;
- }
- }
- function update(fDeltaSecs)
- {
- if(ApplicationState(_global.getApplicationState()).isPaused())
- {
- return undefined;
- }
- if(Key.isDown(37))
- {
- this.m_kPlayer.onRequestTurnLeft();
- }
- else if(Key.isDown(39))
- {
- this.m_kPlayer.onRequestTurnRight();
- }
- else
- {
- this.m_kPlayer.onRequestStop();
- }
- if(!this.m_bFireKeyDown && Key.isDown(32))
- {
- this.m_bFireKeyDown = true;
- this.m_kPlayer.onRequestShootFireBeam();
- }
- }
- }
-