All pastes #1543563 Raw Edit

Unnamed

public text v1 · immutable
#1543563 ·published 2009-08-26 17:31 UTC
rendered paste body
class Ship extends MovieClip
{
	var score;
	var velocity;
	var shootLimiter;
	var enemyTimer;
	var enemies;
	
	function onLoad()
{
	velocity = 10;
	shootLimiter = 0;
	enemyTimer = 0;
	enemies = [];
	resetScore();
}

function updateScore(points)
{
	score += points;
	_root.scoreText.text = score;
}

function onEnterFrame()
{
	shootLimiter += 1;
	
	if( Key.isDown(Key.RIGHT) )
	{
		_x = _x + velocity;
	}
	if( Key.isDown(Key.LEFT) )
	{
		_x = _x - velocity;
	}
	if( Key.isDown(Key.UP) )
	{
		_y = _y - velocity;
	}
	if( Key.isDown(Key.DOWN) )
	{
		_y = _y + velocity;
	}
	
	if( Key.isDown(Key.SPACE) && shootLimiter > 8)
{
	shootLimiter = 0;
	var missles = _root.attachMovie("Missles","Missles" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
	missles._x = _x + 50;
	missles._y = _y + 2;
}

enemyTimer += 1;
if(enemyTimer > 60)
{
	enemyTimer = 0;
	var enemy = _root.attachMovie("EnemyShip", "EnemyShip" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
enemies.push(enemy);
}
}
}


function updateScore(points)
{
	score += points;
	_root.scoreText.text = score;
}

<b>_root.ship.updateScore(50);</b>