Loading...
Logo
Processing Forum
Hi
I am very much a beginner with processing by all means. I really need help with this project where i am trying to flick across random positions on a filmstrip (which is essentially one long .jpg sliding across) by clicking the mouse. So far i have been able to get the strip moving but when i click it only shows the random sections for a single frame. i really want the effect of the strip moving then landing in the random spot while continuing to move.

this is what i have:

PImage img3;
PImage img2;
float y,x;
float speed=0.1;




//SETUP- ALL OF THE IMAGES
void setup(){


  size(678,598);
   img2= loadImage("FILM.jpg");//FILMSTRIP THAT WILL BE MOVING
   img3= loadImage("tv.png");//FRONT IMAGE BLOCKING FILMSTRIP

 
}

void draw(){
  background (0);
 
//MOVING THE FILMSTRIP
pushMatrix();
translate(x,y);
   x+=0.5;
  
image(img2,-23100,0);



popMatrix();
image(img3,0,0);

 
    }
   
    void mousePressed() {
     if(x> -23100) {
        pushMatrix();
      translate(x,y);
   x+=0.5;
  
       image(img2,x,0);
      
       x= random(-23100,678);
   
       popMatrix();
       image(img3,0,0);
      
     }
      
     
    }

ANY help would be so greatly appreciated!!!!!!

Replies(1)

Obviously, we cannot test your code.
General advice: use, in the PDE, Edit > Auto Format (or just hit Ctrl+T) to have a properly formatted code...

Other advice: when you use translate, use 0, 0 as coordinates for the drawing functions (from rect() to image()). In other word, use either translate() or coordinates, but not both.
Perhaps that's the issue you have.

Or not, as I re-read your description... When you click the mouse, you should memorize the random destination in a global variable. Then you find out the direction of movement (positive or negative increment of x) by the sign of the difference between the current position and the final one. And you scroll until you reach the destination.