-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
40 lines (33 loc) · 972 Bytes
/
sketch.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
40
let items = []
let rockImage, paperImage, scissorsImage
let statsBar
function preload() {
rockImage = loadImage('assets/rock.png')
paperImage = loadImage('assets/paper.png')
scissorsImage = loadImage('assets/scissors.png')
}
function setup() {
statsBar = new Stats(windowWidth, 10)
createCanvas(windowWidth, windowHeight);
for (let i = 0; i < 20; i++) {
items.push(new Item(random(0, width), random(0, height), "rock"))
}
for (let i = 0; i < 20; i++) {
items.push(new Item(random(0, width), random(0, height), "paper"))
}
for (let i = 0; i < 20; i++) {
items.push(new Item(random(0, width), random(0, height), "scissors"))
}
}
function draw() {
background(220);
for (let item of items) {
item.wander()
item.seek()
item.show()
item.checkEdge()
item.eat(items)
}
statsBar.sum(items)
statsBar.show()
}