PImage img;
float x = 100; // X-coordinate of image
float y = 100; // Y-coordinate of image
void setup()
{
size(500, 500);
img = loadImage("heart.gif");
image(img, 100, 100);
noStroke();
}
void draw()
{
fill(204, 120);
rect(0, 0, width, height);
fill(0);
// If the cursor is over the image, change the position
if ((mouseX >= x+10) && (mouseX <= x+200) &&
(mouseY >= y-55) && (mouseY <= y+155)) {
x += random(-5, 5);
y += random(-5, 5);
}
image(img, x, y);
}
Wednesday, February 4, 2009
Subscribe to:
Posts (Atom)