aboutsummaryrefslogtreecommitdiffstats
path: root/src/enemies/Red1.ts
blob: 9c508209b35bc3e5c7503427749d6f2bd91d19fb (plain) (blame)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import { Rectangle } from "../Drawable";
import { getSmallDeathAnim, IMGS } from "../Images";
import Enemy from "./Enemy";

export default class Red1 extends Enemy {
  sprite = IMGS.redRight;
  width = IMGS.redRight.width;
  height = IMGS.redRight.height;
  vel = 3
  phase = 0;
  spriteNum = 1;
  i = 0;
  squares: Rectangle[] = [new Rectangle(this, 2, 2, this.width - 2, this.height - 2)]

  move() {
    let dx = 0, dy = 0;

    switch (this.phase) {
      case 0:
        dx = this.vel;
        if (this.x2 > 145) this.phase++;
        // if (this.i++ === 19) this.phase++;
        break;
      case 1:
        this.sprite = IMGS.redRightToDown;
        this.phase++;
        this.i = 0;
        break;
      case 2:
        dx = this.vel;
        dy = this.vel;
        if (this.i++ === 7) this.phase++;
        break;
      case 3:
        this.sprite = IMGS.redDown;
        this.phase++;
        this.i = 0;
        break;
      case 4:
        dy = this.vel;
        // if (this.y > 125) this.phase++;
        if (this.i++ === 19) this.phase++;
        break;
      case 5:
        this.sprite = IMGS.redDownToLeft;
        this.phase++;
        this.i = 0;
        break;
      case 6:
        dx = -this.vel;
        dy = this.vel;
        if (this.i++ === 7) this.phase++;
        break;
      case 7:
        this.sprite = IMGS.redLeft;
        this.phase++;
        this.i = 0;
        break;
      case 8:
        dx = -this.vel;
        // if (this.x < 60) this.phase++;
        if (this.i++ === 19) this.phase++;
        break;
      case 9:
        this.sprite = IMGS.redLeftToUp;
        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.redUp;
        this.phase++;
        this.i = 0;
        break;
      case 12:
        dy = -this.vel
        // if (this.y < 80) this.phase++;
        if (this.i++ === 19) this.phase++;
        break;
      case 13:
        this.sprite = IMGS.redUpToRight;
        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.redRight;
        this.phase++;
        this.i = 0;
        break;
      case 16:
        dx = this.vel
        if (this.x2 > 263) this.phase++;
        // if (this.i++ === 19) this.phase++;
        break;
      case 17:
        this.sprite = IMGS.redRightToDown;
        this.phase++;
        this.i = 0;
        break;
      case 18:
        dx = this.vel
        dy = this.vel
        if (this.i++ === 7) this.phase++;
        break;
      case 19:
        this.sprite = IMGS.redDown;
        this.phase++;
        this.i = 0;
        break;
      case 20:
        dy = this.vel;
        // if (this.y2 > 150) this.phase++;
        if (this.i++ === 19) this.phase++;
        break;
      case 21:
        this.sprite = IMGS.redDownToLeft;
        this.phase++;
        this.i = 0;
        break;
      case 22:
        dx = -this.vel
        dy = this.vel
        if (this.i++ === 7) this.phase++;
        break;
      case 23:
        this.sprite = IMGS.redLeft;
        this.phase++;
        this.i = 0;
        break;
      case 24:
        dx = -this.vel
        // if (this.x < 175) this.phase++;
        if (this.i++ === 19) this.phase++;
        break;
      case 25:
        this.sprite = IMGS.redLeftToUp;
        this.phase++;
        this.i = 0;
        break;
      case 26:
        dx = -this.vel
        dy = -this.vel
        if (this.i++ === 7) this.phase++;
        break;
      case 27:
        this.sprite = IMGS.redUp;
        this.phase++;
        this.i = 0;
        break;
      case 28:
        dy = -this.vel
        // if (this.y < 70) this.phase++
        if (this.i++ === 19) this.phase++;
        break;
      case 29:
        this.sprite = IMGS.redUpToRight;
        this.phase++;
        this.i = 0;
        break;
      case 30:
        dx = this.vel
        dy = -this.vel
        if (this.i++ === 7) this.phase++;
        break;
      case 31:
        this.sprite = IMGS.redRight;
        this.phase++;
        this.i = 0;
        break;
      case 32:
        dx = 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()
  }
  shoot(): boolean { return false }
  deathAnim = getSmallDeathAnim(this)
}