-
-
Save Outrights/00ce882152fb3225fb8c00f255d5d698 to your computer and use it in GitHub Desktop.
My object on mhs master.
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> | |
<html> | |
<head> | |
<title>Multiple Mini-Project on one canvas.</title> | |
<meta name="description" content="[add your bin description]"> | |
<script data-require="p5.js@*" data-semver="0.5.7" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script> | |
</head> | |
<body> | |
<h4>Multiple Mini-Project on one canvas.</h4> | |
<script src="script.js" type="text/javascript"></script> | |
</body> | |
</html> |
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
// Frist | |
var x = 180; | |
var y = 180; | |
var xspeed = 1; | |
var yspeed = 2; | |
function setup() { | |
createCanvas(600, 400); | |
} | |
function draw() { | |
background (25); | |
fill(200); | |
ellipse (x, y, 25, 25); | |
// bounce x | |
x = x + xspeed; | |
if (x > width/2 || x < 0) { | |
xspeed = -xspeed; | |
} | |
// bounce y | |
y = y + yspeed; | |
if (y > height/2 || y < 0) { | |
yspeed = -yspeed; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment