Loading...
Logo
Processing Forum
i have typed out example 5 - 1 from Learning Processing, and on two different machines i am getting an error at the line of my first if statement (line 16 below). i am worried i am mistyping a character or something? 

Copy code
  1. float r = 150; 
  2. float g = 0;
  3. float b = 0; 

  4. void setup(){
  5. size(200,200);
  6. }

  7. void draw(){
  8. background(r,g,b);
  9. stroke(255); 
  10. line (width/2, 0, width/2, height);
  11. }

  12. if(mouseX > width/2){
  13. r = r + 1;
  14.  } else{
  15. r = r - 1;
  16.  }

  17. if (r > 255){
  18.   r = 255;
  19.  } else if (r < 0){
  20.   r = 0;
  21.  }
  22. }

Replies(2)

The problem is that all the code 16-27 are not inside a method/function like draw().

All your other code is inside setup or draw.

HTH
amazing, thank you!