Game Development Reference
In-Depth Information
_angleIncrement = 2 * Math.PI / tunnelSides;
_enemyFrequency = enemyFrequency;
_enemyTime = enemyTime;
_enemyCreator = new Timer(_enemyFrequency*1000);
_enemyCreator.addEventListener(TimerEvent.TIMER,
addEnemy, false, 0, true);
_enemyList = new Dictionary(true);
}
public function startGame():void {
_enemyCreator.start();
addEventListener(Event.ENTER_FRAME, frameScript,
false, 0, true);
}
protected function frameScript(e:Event):void {
movePlayer();
}
protected function movePlayer():void {
var mouseAngle:Number = Math.atan2(mouseY, mouseX);
var roundedAngle:Number = _angleIncrement * Math.
round(mouseAngle/_angleIncrement);
_player.x = _tunnel.radius * Math.cos(roundedAngle);
_player.y = _tunnel.radius * Math.sin(roundedAngle);
var oldRotation:Number = _player.rotation;
_player.rotation = roundedAngle * (180/Math.PI) + 180;
if (oldRotation != _player.rotation) _tunnel.high
lightSide(roundedAngle);
}
protected function addEnemy(e:TimerEvent):void {
var index:int = Math.round(Math.random()*(_tunnel.
sides-1));
var enemy:Enemy = new Enemy(index);
enemy.x = _tunnel.tunnelTiles[0][index].x;
enemy.y = _tunnel.tunnelTiles[0][index].y;
enemy.z = _tunnel.tunnelTiles[_tunnel.depth-1]
[index].z;
enemy.rotation = index * (360/_tunnel.sides) - 180;
enemy.brightness = .5;
addChildAt(enemy, getChildIndex(_player));
_enemyList[enemy] = enemy;
var tween:TweenLite = TweenLite.to(enemy, _enemy
Time, {z:0, brightness:1, ease:Quad.easeIn, onComplete:
enemyMovementFinished, onCompleteParams:[enemy]});
}
Search Nedrilad ::




Custom Search