Created
September 15, 2016 21:35
-
-
Save sabotai/e4b4eaf565859591442a4727ee668375 to your computer and use it in GitHub Desktop.
GD105 Fall 2016 Week 4
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
int x; | |
int y; | |
int w; | |
int h; | |
int bg; | |
Boolean toTheLeft; | |
void setup(){ | |
size(1000,1000); | |
x = 0; | |
y = height/3; | |
w = 100; | |
h = 100; | |
bg = 0; | |
//rectMode(CENTER); | |
toTheLeft = false; | |
} | |
void draw(){ | |
background(bg); //set the background to bw | |
if (mouseX < x){ | |
toTheLeft = true; | |
} else { | |
toTheLeft = false; | |
} | |
if (mouseX < x || //to the left of the box OR | |
mouseX > x+w || //to the right of the box OR | |
mouseY < y || //above the box OR | |
mouseY > y+h){ //below the box... | |
x+=5; //if any of those are true, then move the x position by 5 pixels each frame | |
} else { | |
//if ALL of the above things are NOT true | |
//meaning the only place the cursor can be is | |
//inside the box... | |
bg++; //increase the value of bw, which we use for the background | |
println("you are on the box"); | |
} | |
//x represents the left side | |
//y ... top side | |
//x+w ... right side | |
//y+h ... left side | |
rect(x, y, w, h); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment