Skip to content

Instantly share code, notes, and snippets.

@claytical
Created September 22, 2015 02:36
Show Gist options
  • Save claytical/439865ba122c67ec6f5a to your computer and use it in GitHub Desktop.
Save claytical/439865ba122c67ec6f5a to your computer and use it in GitHub Desktop.
Adding to an Arrya and Displaying Coordinates
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