Skip to content

Instantly share code, notes, and snippets.

@nickgs
Created April 23, 2020 19:28
Show Gist options
  • Save nickgs/7b473dc91b9d225bb0e1411594cf7a91 to your computer and use it in GitHub Desktop.
Save nickgs/7b473dc91b9d225bb0e1411594cf7a91 to your computer and use it in GitHub Desktop.
let value = 0;
let pad1;
let pad2;
function setup() {
createCanvas(windowWidth, windowHeight);
background("black");
pad1 = new Pad(10, 10);
pad2 = new Pad(250, 250);
}
function draw() {
pad1.draw();
pad2.draw();
}
function keyPressed() {
if(keyCode == 68) {
value = random(255);
}
}
class Pad {
constructor(x, y) {
this.x = x;
this.y = y;
}
draw() {
rect(this.x, this.y, 25, 25);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment