exit function - newbie need help

edited December 2017 in Questions about Code

Hello,

im new to programming and picked up processing yesterday. i can draw simple stuff etc.

now i wanted to make the following, a simple black fullscreen and when pressing the esc key the program stops/exits.

the blackscreen is working but i cant seem to get the exit stuff to work can someone please tell me what im doing wrong here?

    void setup() { 
      fullScreen();
      stroke(0);
      fill(0);
      rect(0, 0, 2560, 1440);
    } 

    void keyPressed() {
      if (key==ESC) {
        key=0;
        exit();
          }
    }
Tagged:

Answers

  • Answer ✓
    void setup() { 
      fullScreen();
    }
    
    void draw(){
      background(0);
    }
    
    void keyPressed() { 
      if (key==ESC) { 
        exit();
      }
    }
    

    This works for me.

  • thank you very much!

Sign In or Register to comment.