How to make this boolean true? [closed]


if(mouseX<200 && mouseY<200 && key=='x'){ x1=true; image(X,0,0); key='a';}

Everything else inside this if statement happens, the image is drawn and the key is set to 'a', but the boolean x1 remains false. Does anyone know how I could fix this?


Your conditions states that not only the mouse should be less than 200 on X and Y coordinates but the x key needs to be held down for this condition to be true;

If you want the x1 to be true until you change/clear it one options is to decouple the condition from the draw loop and use something like the keyPressed() event:

boolean x1; PImage X; void setup() { size(400, 400); // placeholder X = createImage(90, 90, RGB); } void draw() { background(255); if (mouseX<200 && mouseY<200 && x1) { image(X, 0, 0); } } void keyPressed() { if (key == 'x'){ x1 = true; } if (key == ' '){ x1 = false; } }

If the mouse position is less than 200 on X and Y and x was pressed the image will be rendered. If the SPACE key is pressed while the image is rendered, the image will disappear as x1 is no longer true.


  • Qt File Dialog Rendered Incorrectly and Crashes
  • Could copy unsigned int bit values as float but float value not returned to the caller function corr
  • Google app engine: how to handle concurrency (racing condition)
  • Wrong localisation in Firebase Cloud Function
  • R code to search a word in a paragraph and copy preceding as well after sentences from key words
  • How to extract details from the xml files using java?
  • Chaining Requests using BlueBird/ Request-Promise
  • How well does Entity Framework 6 support .NET 4.0?
  • How to receive GCM message when app is closed or in background?
  • Generate Quartz Cron Expression Every 2nd monday/friday
  • Error in IE11 caused by babel polyfill - delegate.iterator.return
  • Insert Complete RecordSet to another table in other database MS Access
  • NServiceBus How To Publish Message From 2 Physical Locations Of 1 Logical Service
  • problems using replaceText for special characters: [ ]
  • IE6 postback in asp.net
  • Missing App Store icon codename one build
  • Python Regex[Forking] - Capture Groups Based on Terms but Skipping if another Term in the set is enc
  • How do I force ASP.NET Ajax to use a script from the FS and not WebResource.axd, or to reduce its HT
  • Mask Image to Video Frame similar as MV Master
  • get all files in git diff in intellij
  • Multiple git user in single device
  • DocuSign API Replace template document but keep fields
  • How to adapt DirectX-style world/view/projection matrices to OpenGL?
  • Insert statement not working using execute(array()) of PDO Extension
  • Android NDK refer to external libraries in JNI
  • Sum children values and save result to parent in n-ary tree in Javascript
  • spring security manual login best practice
  • Use 2D Text into 3D scenes in JavaFX results in blurry texts
  • Query regarding com.jcraft.jsch.JSchException: UnknownHostKey: x.y.com. DSA key fingerprint is “ac:e
  • Implementation of timeout in LDAP
  • Find all parks for a given zipcode with google maps
  • How to control xtics in gnuplot
  • Run a form (insert/update/delete) from within a div using jquery
  • What does “T extends Junk” mean in a generic class in Java?
  • How to resolve this in PHPUnit where it is asking me to set KERNEL_DIR in my phpunit.xml?
  • Why my AngularJS async test in Jasmine 1.3.x is not working?
  • Capture SIGFPE from SIMD instruction
  • How to use FirstOrDefault inside Include
  • WPF custom control and direct content support