Last active
October 7, 2020 19:31
-
-
Save nickgs/01e6319a44d7aa857b4491c7535b3a51 to your computer and use it in GitHub Desktop.
DVDLogo.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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