-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.js
More file actions
39 lines (30 loc) · 766 Bytes
/
Copy pathblock.js
File metadata and controls
39 lines (30 loc) · 766 Bytes
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
export class Block {
x = 1000
y = 1000
width = 300
height = 100
e = true
async update() {
if(this.e){
this.y += 5
if (this.y > 950) {
this.y = -50
this.e = false
await this.sleep(this.Rand(1500))
var rand = this.Rand(5)
this.x = -62 + 300 + (300 * rand)
this.e = true
}
console.log(this.y, this.x)
}
}
async sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
Rand(maxLimit = 1){
let rand = Math.random() * maxLimit;
console.log(rand);
rand = Math.floor(rand);
return rand;
}
}