How do I constrain an image that moves via mouseY ?

edited October 2017 in Questions about Code


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)



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() {
  tint(255, 255);

  image(field, 0, 0);

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

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


Sign In or Register to comment.