float x;
float ypos;
float y;
float direction;
float speed;
float speedy = 20;
PImage HappyBunny;
PImage HappyBunny2;
void setup(){
size(600, 400);
HappyBunny = loadImage("HappyBunny.png");
HappyBunny2 = loadImage("HappyBunny2.png");
}
void draw() {
background(255);
fill(200);
if (mousePressed == true) {
speed = 0;
ypos = mouseY;
strokeWeight(3);
image(HappyBunny2, mouseX - 80, ypos - 90, 130, 150);
}
else {
speed = speedy;
image(HappyBunny, mouseX - 80, ypos - 90, 130, 150);
if (ypos > mouseY + 50) {
direction = -1;
}
if (ypos < mouseY - 50) {
direction = 1;
}
ypos = ypos + ( speed * direction );
}
}
Alexis - L
on Monday, Nov 24, 2008 – 1:56 am