<html>
  <head></head>
</html>
var ballX=0;
var ballY=30;
var ballSpeed=1;

function setup(){
  createCanvas(400, 300);
}

function draw() {
  background(150, 0, 0);  
  fill(150);
  if(ballX>width || ballX<0){
    ballSpeed = ballSpeed * -1
  }
  
  ballX=ballX+ballSpeed;
  ellipse(ballX,ballY,30,30); 
  textSize(32);
  text("Hello World", random(width), random(height));
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.4/p5.js