We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi, I have this code. Basically I want that when the mouseY is < than height/2 my variable will change, and depending on that I will draw a different rect. The thig is that the if statements to deal with myB variable aren't actually doing what I want..they keep changing..so where do I put them? I just want myB = 0 and stays that until mouseY < height/2, then myB = 1 and stays that until the next time mouseY < height/2, then myB = 2 and stays that until mouseY < height/2 and then going back to 0
int myB = 0;
void draw(){
if(myB == 0){
fill(255,0,0);
rect(0,0,width/2,height/2);
}
if(myB == 1){
fill(0,255,0);
rect(0,0,width/2,height/2);
}
if(myB == 2){
fill(0,0,255);
rect(0,0,width/2,height/2);
}
change();
}
void change(){
if(mouseY < height/2){
if(myB == 0)
myB = 1;
else if(myB == 1)
myB = 2;
else if(myB == 2)
myB = 0;
}
}
Answers
thank you both..yes I know how processing works but every time I have to deal with this kind of code I struggle..thank you again!
just to clarify..if I write (inside the draw) this code
when it gets executed (60 fps), in every of those 60fps it will check whether something is true or false right? then for example
frame 1 something = true; => do this frame 2 something = false; => do that
am I right?
Yes.
good. thank you!