We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
https://Processing.org/reference/constrain_.html
Thanks, I'd started looking at examples of constrain in use but can't figure out how and where to use it correctly.
image(flag, 125, constrain(mouseY, 0, height - 100), 200, 100);
thanks