How do I constrain an image that moves via mouseY ?

edited October 2017 in Questions about Code

Hello

First post, first use of processing, level basic, code fudged...

I'm trying to get the equivalent of a flag to run up a flagpole via mouseY but want to stop the image at the bottom and top. What metalanguage should I be searching for to help me to do this? Code posted below so far, (one flag image is replaced with another)

Thanks

Lukas

PImage field;
PImage flag;
PImage whiteflag;

void setup() {

  size(600, 399); // size of field file is size of window for now
  flag = loadImage("flag.jpg");  // Load the image
  field = loadImage("fieldnpole.jpg");  // Load the image
  whiteflag = loadImage("whiteflag.jpg");  // Load the image
}


void draw() {
  background(0);
  tint(255, 255);


  image(field, 0, 0);


  image(whiteflag, 125, mouseY, 200, 100);

  tint(255, 255, 255, mouseY);
  image(flag, 125, mouseY, 200, 100);
}

Answers

Sign In or Register to comment.