Skip to content

Instantly share code, notes, and snippets.

@jdguzman230
Forked from aurelianonava/index.html
Created October 11, 2017 16:20
Show Gist options
  • Save jdguzman230/7068790a3e9a5f2858c6479a35511268 to your computer and use it in GitHub Desktop.
Save jdguzman230/7068790a3e9a5f2858c6479a35511268 to your computer and use it in GitHub Desktop.
My object on mhs master.
<!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>
// 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