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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
import { Rectangle } from "../Drawable";
import { getSmallDeathAnim, IMGS } from "../Images";
import Enemy from "./Enemy";
export default class Red2 extends Enemy {
sprite = IMGS.redDown;
width = IMGS.redDown.width;
height = IMGS.redDown.height;
vel = 2;
phase = 0;
i = 0;
squares: Rectangle[] = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)]
constructor(x: number, y: number, public left: boolean) {
super(x, y)
}
move() {
let dx = 0, dy = 0;
switch (this.phase) {
case 0:
dy = this.vel;
if (this.y > 163) this.phase++;
break;
case 1:
this.sprite = IMGS.redDownToRight
this.phase++
this.i = 0;
break;
case 2:
dx = this.vel
dy = this.vel
if (this.i++ === 9) this.phase++;
break;
case 3:
this.sprite = IMGS.redRight
this.phase++
this.i = 0;
break;
case 4:
dx = this.vel
if (this.x > (this.left ? 285 : 285 + 80)) this.phase++;
break;
case 5:
this.sprite = IMGS.redRightToUp
this.phase++
this.i = 0;
break;
case 6:
dx = this.vel
dy = -this.vel
if (this.i++ === 13) this.phase++;
break;
case 7:
this.sprite = IMGS.redUp
this.phase++;
break;
case 8:
dy = -this.vel
if (this.y < 98) this.phase++
break;
case 9:
this.sprite = IMGS.redUpToLeft
this.phase++
this.i = 0;
break;
case 10:
dx = -this.vel
dy = -this.vel
if (this.i++ === 7) this.phase++;
break;
case 11:
this.sprite = IMGS.redLeft
this.phase++
this.i = 0;
break;
case 12:
dx = -this.vel
if (this.x < (this.left ? 210 : 210 + 80)) this.phase++
break;
case 13:
this.sprite = IMGS.redLeftToDown
this.phase++
this.i = 0
break;
case 14:
dx = -this.vel
dy = this.vel
if (this.i++ === 7) this.phase++;
break;
case 15:
this.sprite = IMGS.redDown
this.phase++
this.i = 0
break;
case 16:
dy = this.vel
break;
default:
break;
}
this.x += dx;
this.y += dy;
this.width = this.sprite.width
this.height = this.sprite.height
this.squares = [new Rectangle(this, 2, 2, this.width - 4, this.height - 4)]
return this.isOutsideMap() && this.phase > 12
}
shoot(): boolean { return false }
deathAnim = getSmallDeathAnim(this)
}
|