Source of: Colorful Bouncing Ball, by Grok Build 0.1
29 lines, no comments ยท 1,750 tokens, written in 9 seconds for $0.0037
1 let x, y;
2 let xs, ys;
3 let col;
4
5 function setup() {
6 createCanvas(600, 400);
7 x = width / 2;
8 y = height / 2;
9 xs = 4;
10 ys = 3;
11 col = color(255, 0, 0);
12 }
13
14 function draw() {
15 background(20);
16 fill(col);
17 noStroke();
18 ellipse(x, y, 50, 50);
19 x += xs;
20 y += ys;
21 if (x > width - 25 || x < 25) {
22 xs *= -1;
23 col = color(random(255), random(255), random(255));
24 }
25 if (y > height - 25 || y < 25) {
26 ys *= -1;
27 col = color(random(255), random(255), random(255));
28 }
29 }