float moveX, moveY, easing, speed;
void setup() {
size(400,400);
smooth();
noStroke();
fill(137,131,131);
frameRate(12);
}
void draw(){
background(0);
rect(moveX, moveY,30,30);
}
//when the mouse is moving around normally the square wants to be friends
//but it timid and therfore approaches slowly and follows froma distance
void mouseMoved(){
frameRate(5);
easing = 0.01;
moveX = mouseX;
moveY = mouseY;
}
//when the mouse is dragging it is becasue the mouse is mad at the square,
//therefore the square retreats to the corner and comes out only as the mouse
//gets happier (moves faster)
void mouseDragged(){
frameRate(12);
speed = dist(mouseX,mouseY,pmouseX,pmouseY);
moveX = speed;
moveY = speed;
}
//when the mouse is clicked once it is essentially yelling at the square
//so the square gets really scared and hides
void mousePressed(){
moveX = mouseX+400;
moveY=mouseY+400;
}
//when the mouse is released it is apologizing so and the square is eager to
//be friends again and comes back quickly to hug the mouse
void mouseReleased(){
moveX = mouseX - 15;
moveY = mouseY - 15;
}
Jessica - H
on Monday, Oct 20, 2008 – 12:28 pm