Boolean variable help!
in
Programming Questions
•
2 years ago
I have defined a boolean variable "retro" false and I have my code setup so that if you press and hold the "r" key it will set it to "true" and if you release the "r" key it will set it to false and it will print if the variable is true or false. Well, when I ran the sketch it was already saying retro equaled true before I had pressed anything. Here are a few snippits of code if you need them.
Thanks,
TheGamersHaven
- boolean retro = false;
-
void ball() {if (retro = false) {smooth();noStroke();fill(255,50);rectMode(CORNER);stroke(0);rect(0,0,width,height);fill(0);ellipse(mouseX,mouseY,10,10);}if (retro = true) {noSmooth();fill(0,50);rectMode(CORNER);rect(0,0,width,height);stroke(0,255,0);ellipse(mouseX,mouseY,10,10);}}
void keyPressed() {if (key == 'r' || key == 'R') {retro = true; //Enables retro mode.}}
void keyReleased() {if (key == 'r' || key == 'R') {retro = false; //Disables retro mode.}}
I've been looking over my code for awhile and I couldn't find the reason why it isn't working... If you need anything else feel free to ask. I won't be able to respond, though, for a five to six hours because of school.
Also, if you could help me out with a previous problem, that would be just great.
Thanks,
TheGamersHaven
1