Skip to content

Instantly share code, notes, and snippets.

@nickgs
Last active October 7, 2020 19:31
Show Gist options
  • Save nickgs/01e6319a44d7aa857b4491c7535b3a51 to your computer and use it in GitHub Desktop.
Save nickgs/01e6319a44d7aa857b4491c7535b3a51 to your computer and use it in GitHub Desktop.
DVDLogo.js
let xpos = 0;
let ypos = 0;
let xdir = 10;
let ydir = 10;
function setup() {
createCanvas(windowWidth, windowHeight);
background("black");
xpos = 20;
ypos = 20;
}
function draw() {
background("black");
fill('rgba(255, 0, 0, .8)');
rect(xpos, ypos, 150, 100);
// Right and left walls
if(xpos >= windowWidth-150 || xpos <= 0) {
xdir *= -1;
}
// Ceiling and the floor
if(ypos >= windowHeight-100 || ypos <= 0) {
ydir *= -1;
}
xpos += xdir;
ypos += ydir;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment