calling a function

edited November 2013 in Using Processing

How do I type the function I have so that it is called in setup?

//this is my set up
void setup() {
 size(362,362);
 cell(x_global, y_global, s_global, color(255));
 triple(x_global,y_global, s_global, color(255));
 block(x_global,y_global, s_global, color(255));
 row(x_global,y_global, s_global, color(255));
 cellarray(x_global,y_global, s_global, color(255));
board();
drawLines();
}


//I want to call both in set up
void board() {
cellarray(x_global, y_global, s_global);
drawLines();
}

void draw() {
if (mousePressed) {
fill(255, 0, 0);
ellipse(x_global+s_global*cell_x+s_global/2,
y_global+s_global*cell_y+s_global/2,
s_global/4, s_global/4);
}

Answers

  • Could you please repost your code, highlight it, then hit CTRL+K to format it? :-O

  • edited November 2013 Answer ✓

    Still code format is a mess. Even before posting, inside Processing's IDE, hit CTRL+T there to make code neat!
    That's what I did for you this time:

    // forum.processing.org/two/discussion/1583/calling-a-function
    
    void setup() { 
      size(362, 362);
    
      cell(x_global, y_global, s_global, color(255));
      triple(x_global, y_global, s_global, color(255));
      block(x_global, y_global, s_global, color(255));
      row(x_global, y_global, s_global, color(255));
      cellarray(x_global, y_global, s_global, color(255));
    
      board();
      drawLines();
    }
    
    void draw() { 
      if (mousePressed) { 
        fill(#FF0000); 
    
        ellipse(x_global+s_globalcell_x+s_global/2
          , y_global+s_globalcell_y+s_global/2
          , s_global/4
          , s_global/4);
      }
    }
    
    void board() { 
      cellarray(x_global, y_global, s_global);
      drawLines();
    }
    
  • I don't understand the question, the board() function is already called in setup().

Sign In or Register to comment.