30 lines, 5 of them comments ยท 274 tokens, written in 7 seconds for $0.0002


 1  function setup() {
 2    createCanvas(400, 400);
 3    // Initial position of the ball
 4    this.x = width / 2;
 5    this.y = height / 2;
 6    // Speed of the ball
 7    this.xSpeed = 3;
 8    this.ySpeed = 2;
 9  }
10  
11  function draw() {
12    background(220);
13    
14    // Draw the ball
15    fill(255, 0, 0);
16    noStroke();
17    ellipse(this.x, this.y, 30, 30);
18    
19    // Update position
20    this.x += this.xSpeed;
21    this.y += this.ySpeed;
22    
23    // Bounce off the edges
24    if (this.x < 15 || this.x > width - 15) {
25      this.xSpeed *= -1;
26    }
27    if (this.y < 15 || this.y > height - 15) {
28      this.ySpeed *= -1;
29    }
30  }