Created
September 22, 2015 02:36
-
-
Save claytical/439865ba122c67ec6f5a to your computer and use it in GitHub Desktop.
Adding to an Arrya and Displaying Coordinates
This file contains hidden or 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
| var selectedBall; | |
| var xCoordinates; | |
| var yCoordinates; | |
| function setup() { | |
| createCanvas(windowWidth, windowHeight); | |
| selectedBall = 0; | |
| xCoordinates = []; | |
| yCoordinates = []; | |
| } | |
| function draw() { | |
| background(0); | |
| textSize(30); | |
| textAlign(LEFT); | |
| fill(255); | |
| text("X COORDINATES: " + xCoordinates.join(), 30, 30); | |
| text("LAST COORDINATE SET: " + xCoordinates[xCoordinates.length - 1] + "," + yCoordinates[yCoordinates.length - 1], 30, 60); | |
| } | |
| function mousePressed() { | |
| xCoordinates.push(mouseX); | |
| yCoordinates.push(mouseY); | |
| } | |
| function keyPressed() { | |
| xCoordinates.sort(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment