31 lines, 3 of them comments ยท 225 tokens, written in 2 seconds for $0.017


 1  let ball = {
 2    x: 100,
 3    y: 100,
 4    xSpeed: 3,
 5    ySpeed: 2,
 6    radius: 20
 7  };
 8  
 9  function setup() {
10    createCanvas(400, 400);
11  }
12  
13  function draw() {
14    background(220);
15  
16    // Draw the ball
17    ellipse(ball.x, ball.y, ball.radius * 2);
18  
19    // Update the ball's position
20    ball.x += ball.xSpeed;
21    ball.y += ball.ySpeed;
22  
23    // Check for collisions with walls
24    if (ball.x < ball.radius || ball.x > width - ball.radius) {
25      ball.xSpeed *= -1;
26    }
27  
28    if (ball.y < ball.radius || ball.y > height - ball.radius) {
29      ball.ySpeed *= -1;
30    }
31  }