Built with blockbuilder.org
Created
April 14, 2016 07:24
-
-
Save Utopiah/42fa9fbd2e1dfa2874a087fdc105337b to your computer and use it in GitHub Desktop.
fresh block
This file contains 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>p5js Template</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.13/p5.js"></script> | |
<script> | |
var x, y, xSpeed, ySpeed; | |
function setup() { | |
createCanvas(400,300); | |
x = random(width); | |
y = random(height); | |
xSpeed = 3; | |
ySpeed = 3; | |
} | |
function draw() { | |
background(100); | |
stroke(255); | |
strokeWeight(4); | |
noFill(); | |
ellipse(x,y,20,20); | |
if(x < 0 || x > width){ | |
xSpeed *= -1.28; | |
} | |
if(y < 0 || y > height){ | |
ySpeed *= -1; | |
} | |
x = x + xSpeed; | |
y = y + ySpeed; | |
} | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment