complete exercise 0.7

This commit is contained in:
Rokas Puzonas 2024-02-05 22:13:49 +02:00
parent c5c6ec4fee
commit 33939aeffd
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/p5@1.9.0/lib/p5.js"></script>
<script src="sketch.js"></script>
<style>
body {
background: #212121;
}
</style>
</head>
<body>
<main>
</main>
</body>
</html>

View File

@ -0,0 +1,37 @@
class Walker {
constructor(x = 0, y = 0) {
this.tx = 0
this.ty = 10000
this.x = x
this.y = y
}
step() {
let dx = map(noise(this.tx), 0, 1, -1, 1)
let dy = map(noise(this.ty), 0, 1, -1, 1)
this.x += dx
this.y += dy
this.tx += 0.01
this.ty += 0.01
}
draw() {
stroke(0)
point(this.x, this.y)
}
}
let walker
function setup() {
createCanvas(640, 240)
background(255)
walker = new Walker(320, 120)
}
function draw() {
walker.step();
walker.draw();
}