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

From Inside
Jump to: navigation, search
>Zachary.logsdon
(New page: {{GSDP:GAM100API.css}} = Terminate() = == Description == This will end the program after completing the current frame. == Example Usage == <syntaxhighlight lang='c'> // Horizontal positi...)
 
>Zachary.logsdon
 
Line 36: Line 36:
 
}
 
}
  
int main(void)
+
CP_main
 
{
 
{
 
   // Set the initial game state
 
   // Set the initial game state
Line 50: Line 50:
 
* [[GSDP:GAM100/CProcessing|Main Page]]
 
* [[GSDP:GAM100/CProcessing|Main Page]]
 
* [[GSDP:GAM100/CProcessing/Run()|Run()]]
 
* [[GSDP:GAM100/CProcessing/Run()|Run()]]
 +
* [[GSDP:GAM100/CProcessing/CP_main|CP_main]]
 
* [[GSDP:GAM100/CProcessing/Terminate()|Terminate()]]
 
* [[GSDP:GAM100/CProcessing/Terminate()|Terminate()]]
 
* [[GSDP:GAM100/CProcessing/SetNextGameState()|SetNextGameState()]]
 
* [[GSDP:GAM100/CProcessing/SetNextGameState()|SetNextGameState()]]
 
* [[GSDP:GAM100/CProcessing/SetNextGameStateForced()|SetNextGameStateForced()]]
 
* [[GSDP:GAM100/CProcessing/SetNextGameStateForced()|SetNextGameStateForced()]]

Latest revision as of 09:42, 20 October 2019

Terminate()

Description

This will end the program after completing the current frame.

Example Usage

// Horizontal position of the square
float x_pos;
void init()
{
  // Start the square at the left of the screen
  x_pos = 0;

  // Set the square to draw yellow
  fill(color(255, 255, 0, 255));
}

void update()
{
  // Set background to black
  background(color(0, 0, 0, 255));

  // Draw the square
  rect(x_pos, (float)canvasHeight / 2.0f, 100, 100);
  x_pos += 2;

  // If space pressed, reset the state 
  if (keyPressed(KEY_SPACE))
    SetNextGameStateForced(init, update, NULL);

  // If q is pressed, end the program
  else if (keyPressed(KEY_Q))
    Terminate();
}

CP_main
{
  // Set the initial game state
  SetNextGameState(init, update, NULL);

  // Run the program
  Run();    
}

See Also

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>