-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ship.as
35 lines (31 loc) · 883 Bytes
/
Ship.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class Ship extends MovieClip {
var velocity;
var shootLimiter;
var enemyTimer;
var enemies;
function onLoad() {
velocity = 10;
shootLimiter = 0;
enemyTimer = 0;
enemies = [];
}
function onEnterFrame() {
shootLimiter += 1;
enemyTimer += 1;
if (enemyTimer > 60) {
enemyTimer = 0;
var enemy = _root.attachMovie("EnemyShip", "EnemyShip"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
enemies.push(enemy);
}
if (Key.isDown(Key.RIGHT)) {_x += velocity;}
if (Key.isDown(Key.LEFT)) {_x -= velocity;}
if (Key.isDown(Key.UP)) {_y -= velocity;}
if (Key.isDown(Key.DOWN)) {_y += velocity;}
if (Key.isDown(Key.SPACE) && shootLimiter > 8) {
shootLimiter = 0;
var missile = _root.attachMovie("Missile", "Missile"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
missile._x = _x+48;
missile._y = _y+3;
}
}
}