Skip to content

Instantly share code, notes, and snippets.

@Outrights
Forked from aurelianonava/index.html
Created October 10, 2017 19:02
Show Gist options
  • Save Outrights/00ce882152fb3225fb8c00f255d5d698 to your computer and use it in GitHub Desktop.
Save Outrights/00ce882152fb3225fb8c00f255d5d698 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