PImage copacabana; float xpos; float ypos; float drag = 50.0; void setup() { size(860,430); copacabana = loadImage("copacabana.jpg"); //XPos indicates the X position of the center of the floating image xpos = width/2; //yPos indicates the Y position of the center of the floating image ypos = height/2; frameRate(48); } void draw() { //float difx = mouseX - xpos-copacabana.width/2; float distMovx = mouseX - xpos-750; if(abs(distMovx) > 1.0) { xpos = xpos + distMovx/drag; //constrain (value,x minimum boundary,x maximum boundary) ; xpos = constrain(xpos, -640, 0); } float distMovy = mouseY - ypos-copacabana.height/2; if(abs(distMovy) > 1.0) { ypos = ypos + distMovy/drag; //constrain (value,y minimum boundary,y maximum boundary) ; ypos = constrain(ypos, -570, 0); } // Display the mi image at the new position xpos, ypos image(copacabana, xpos, ypos); //HERE WE CALL THE FUNCTION TO DRAW HORIZONTAL LINES............................................. drawMouselines (); drawlines (); } //FUNCTION TO DRAW HORIZONTAL LINES................................................................. void drawlines () { int y=0; while (y<580) { line (0,y,860,y); y=y+2; } } void drawMouselines () { line (mouseX,mouseY,mouseX,mouseY+1000); line (mouseX,mouseY,mouseX,mouseY-1000); //line (mouseX,mouseY,mouseX+1000,mouseY); //line (mouseX,mouseY,mouseX-1000,mouseY); }