nick34992
4/20/2016 - 3:35 AM

Click Create P. Using p5.js library.

Click Create P. Using p5.js library.

// Based on code featured in one of Shiffman's video tutorials

var canvas;
var h1;
var x = 100;
var y = 100;

function setup () {
  canvas = createCanvas(600,400);
  canvas.position(400,300);
  h1 = createElement('h1','Click Me.');
  //h1.position (400,600);
}

function mousePressed() {
  h1.html("Keep clicking for random numbers.");
  createP("Another random number " + random(0,10));
}

function draw () {
  background(200);
  fill(255,0,0);
  rect (x,y,50,50);
  h1.position(x,y);
  x = x + random(-5,5);
}