-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvet1.html
More file actions
38 lines (32 loc) · 984 Bytes
/
vet1.html
File metadata and controls
38 lines (32 loc) · 984 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
<html>
<head>
<title>Vector 1 - Introduction</title>
<script src="https://cdn.jsdelivr.net/npm/p5@1.5.0/lib/p5.min.js"></script>
<script>
class Walker {
constructor(x, y) {
this.pos = createVector(width / 2, height / 2);
}
update() {
this.pos.x += random(-1, 1);
this.pos.y += random(-1, 1);
}
show() {
stroke(255);
strokeWeight(3);
point(this.pos.x, this.pos.y);
}
}
var walker;
function setup() {
createCanvas(200, 200);
background(51);
walker = new Walker();
}
function draw() {
walker.update();
walker.show();
}
</script>
</head>
</html>