Difference between revisions of "GSDP:GAM100/CProcessing/Run()"
From Inside
< GSDP:GAM100 | CProcessing
>Zachary.logsdon |
>Zachary.logsdon |
||
Line 1: | Line 1: | ||
{{GSDP:GAM100API.css}} | {{GSDP:GAM100API.css}} | ||
== Description == | == Description == | ||
− | This function is what | + | This function is what starts the CProcessing engine. Before calling run(), [[GSDP:GAM100/CProcessing/SetNextGameState()|SetNextGameState()]] or [[GSDP:GAM100/CProcessing/SetNextGameStateForced()|SetNextGameStateForced()]] must be called to set the initial state of the program. Failing to do so will make the program end immediately. |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Example Usage == | == Example Usage == | ||
Line 13: | Line 7: | ||
void init(void) | void init(void) | ||
{ | { | ||
− | + | /* Set the size of the window */ | |
− | + | size(500, 500); | |
} | } | ||
void update(void) | void update(void) | ||
{ | { | ||
− | + | /* Set the background color to black every frame */ | |
− | + | background(color(0, 0, 0, 255)); | |
− | + | /* Draw a rectangle at the mouse position */ | |
− | + | rect(mouseX, mouseY, 50, 50); | |
} | } | ||
int main(void) | int main(void) | ||
{ | { | ||
− | + | // Set the initial game state | |
− | + | SetNextGameState(init, update); | |
+ | |||
+ | // Run the program | ||
+ | Run(); | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
=== See Also === | === See Also === | ||
* [[GSDP:GAM100/CProcessing|Main Page]] | * [[GSDP:GAM100/CProcessing|Main Page]] | ||
+ | * [[GSDP:GAM100/CProcessing/Run()|Run()]] | ||
+ | * [[GSDP:GAM100/CProcessing/Terminate()|Terminate()]] | ||
+ | * [[GSDP:GAM100/CProcessing/SetNextGameState()|SetNextGameState()]] | ||
+ | * [[GSDP:GAM100/CProcessing/SetNextGameStateForced()|SetNextGameStateForced()]] |
Revision as of 10:41, 13 October 2019
Description
This function is what starts the CProcessing engine. Before calling run(), SetNextGameState() or SetNextGameStateForced() must be called to set the initial state of the program. Failing to do so will make the program end immediately.
Example Usage
void init(void)
{
/* Set the size of the window */
size(500, 500);
}
void update(void)
{
/* Set the background color to black every frame */
background(color(0, 0, 0, 255));
/* Draw a rectangle at the mouse position */
rect(mouseX, mouseY, 50, 50);
}
int main(void)
{
// Set the initial game state
SetNextGameState(init, update);
// Run the program
Run();
}