Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ship extends MovieClip
- {
- var velocity;
- var shootLimiter;
- var enemyTimer;
- var enemies;
- var score;
- function resetScore()
- {
- score = 0;
- _root.scoreText.text = score;
- }
- function onLoad()
- {
- velocity = 10;
- shootLimiter= 0;
- enemyTimer = 0;
- enemies = [];
- resetScore();
- _root.gameOverMenu._visible = false;
- }
- 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 > 200)
- {
- shootLimiter= 0;
- var missile = _root.attachMovie( "Missile" , "Missile" + _root.getNextHighestDepth(), _root.getNextHighestDepth() );
- missile._x = _x + 50;
- missile._y = _y + 20;
- }
- 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;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement