Difference between revisions of "GSDP:GAM100/CProcessing/Run()"

From Inside
Jump to: navigation, search
>D.hamilton
>D.hamilton
Line 10: Line 10:
 
== Example Usage ==
 
== Example Usage ==
 
<syntaxhighlight lang="c" line='line'>
 
<syntaxhighlight lang="c" line='line'>
void setup(void)
+
void init(void)
 
{
 
{
 
     /* Set the size of the window */
 
     /* Set the size of the window */
Line 16: Line 16:
 
}
 
}
  
void draw(void)
+
void update(void)
 
{
 
{
 
     /* Set the background color to black every frame */
 
     /* Set the background color to black every frame */

Revision as of 13:13, 14 September 2018

Description

This function is what runs your program for you. When you write setup() and draw() functions in your work space, then you call Run with the names of those functions to loop your program.


Setup will be called exactly once at the beginning of the program. Draw will be called once per frame for the life of the program.


The setup() and draw() functions must take no parameters and return nothing.

Example Usage

 1void init(void)
 2{
 3    /* Set the size of the window */
 4    size(500, 500);
 5}
 6
 7void update(void)
 8{
 9    /* Set the background color to black every frame */
10    background(0, 0, 0, 255);
11
12    /* Draw a rectangle at the mouse position */
13    rect(mouseX, mouseY, 50, 50);
14}
15
16int main(void)
17{
18    /* Run the program */
19    Run(setup, draw);    
20}


See Also

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>