-
Notifications
You must be signed in to change notification settings - Fork 0
/
exhaust.js
39 lines (33 loc) · 906 Bytes
/
exhaust.js
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
const exhaustArray = [];
class Exhaust {
constructor(){
this.x = tama.x - 8;
this.y = tama.y - 10;
this.size = Math.random() * 7 + 3;
this.speedY = (Math.random() * 1) - 0.5;
this.color = 'hsla(' + hue +', 100%, 50%, 0.8)';
}
update(){
this.x -= gamespeed;
this.y += this.speedY;
}
draw(){
ctx.fillStyle = this.color;
if (!spacePressed) ctx.fillStyle = 'transparent';
ctx.beginPath();
ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
ctx.fill();
}
}
function handleExhaust(){
exhaustArray.unshift(new Exhaust);
for (i = 0; i < exhaustArray.length; i++){
exhaustArray[i].update();
exhaustArray[i].draw();
}
if (exhaustArray.length > 10 ){
for (let i = 0; i < 20; i++){
exhaustArray.pop(exhaustArray[i])
}
}
}