Skip to content

Instantly share code, notes, and snippets.

@slambert
Created September 15, 2015 16:40
Show Gist options
  • Select an option

  • Save slambert/8e3ead820543f262a337 to your computer and use it in GitHub Desktop.

Select an option

Save slambert/8e3ead820543f262a337 to your computer and use it in GitHub Desktop.
offMouse
/*
Steve Lambert
offMouse
September 15, 2015
Note: where you declare your variable
*/
// Global Variables (usable in every loop/function we make)
int offMouse = 0; //declare AND initialize the variable
void setup(){
size(600,600);
}
void draw(){
offMouse = mouseX + 50; // calculate the change in position
// when we calculated this in setup, it didn't change. We need it
// to be continually recalculated as the mouse moves
background(0); // black
ellipse(offMouse,mouseY,20,20);
println("X: " + mouseX + " | offMouse: " + offMouse + " | Y: " + mouseY);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment