Skip to content

Instantly share code, notes, and snippets.

@dannyalberto
Last active October 5, 2017 19:42
Show Gist options
  • Save dannyalberto/477ea1d2d72bfd0db28b60faf1452af9 to your computer and use it in GitHub Desktop.
Save dannyalberto/477ea1d2d72bfd0db28b60faf1452af9 to your computer and use it in GitHub Desktop.
Project 2, Version 1// source http://jsbin.com/dafopin
<!DOCTYPE html>
<html>
The reason for the movement of the circle is because of the greater sign(>) next to the x variable, in the ''if conditional statement''( if (x>240) ).The greater sign makes the x variable move into the direction the sign points to,
therefore replacing a greater sign instead of a number.With this, the Function draw runs 60 times a second, while this happening, the speed what picked up and then moved(the if conditional statement , the greater sing changed on the x axis of the funcion).
<head>
<meta name"description" content=""[Projec for issue #16 and explanation]">
<title>Project 2, Version 1</title>
<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>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>
<body>
<h1>Issue #16</h1>
<a href="https://github.com/aurelianonava/mhs/issues/16">Issue #16 on the mhs Github repsitory</a></br>
</body>
</html>
// Code goes here
var x = 10;
function setup() {
createCanvas (480, 420);
}
function draw() {
background(120,200,150);
ellipse(x+=1, 25, 25, 25);
strokeWeight(1);
point(x+=.5, 25);
if ( x > 240 ) {
x = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment