hello i need help with my code. i need to be able to click the picture with the cross hair and for it to fall but nothing ive done seems to work. if possible could you guys show me how to do it using a while loop? also hi m new
int rate = 1000000000;
int rad = 10;
int xpos, ypos;
int xspeed = 1;
int yspeed = 1;
int xdirection = 4;
int ydirection = 5;
PImage img;
int vrint = 1;
float i = 0;
void setup() {
size(800, 400);
frameRate(rate);
xpos = width/2;
ypos = height/2;
}
void draw(){
background(102, 204, 255);
display();
xpos = xpos + ( xspeed * xdirection );
ypos = ypos + ( yspeed * ydirection );
if (xpos > width-rad || xpos < rad) {
xdirection *= -1;
xpos += random(-1.1,1.1);
}
if (ypos > height-rad || ypos < rad) {
ydirection *= -1;
ypos += random(-1.1,1.1);
}
}
void display(){
img = loadImage("vrinten1.png");
image(img, xpos, ypos, width/9, height/9);
img = loadImage("rock1.png");
image(img, 0, 360, width/9, height/9);
img = loadImage("groundsprite.png");
image(img, 0, 335, height, width/9);
img = loadImage("groundsprite.png");
image(img, 200, 335, height, width/9);
img = loadImage("groundsprite.png");
image(img, 400, 335, height, width/9);
img = loadImage("groundsprite.png");
image(img, 600, 335, height, width/9);
if (mousePressed) {
stroke(255);
} else {
stroke(0);
}
line(mouseX-20, mouseY, mouseX+20, mouseY);
line(mouseX, mouseY-20, mouseX, mouseY+20);
}
void mouseReleased() {
while(mouseX ==xpos && mouseY==ypos){
img = loadImage("groundsprite.png");
image(img, 0, 100, height, width/9);
}
}