GSDP:GAM100/CProcessing/CP Engine Terminate()

From Inside
< GSDP:GAM100‎ | CProcessing
Revision as of 23:45, 19 September 2020 by >Justin.chambers (New page: {{GSDP:GAM100API.css}} = CP_Engine_Terminate() = == Description == This will end the program after completing the current frame. == Example Usage == <syntaxhighlight lang='c'> // Horizont...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

CP_Engine_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
  CP_Settings_Fill(CP_Color_Create(255, 255, 0, 255));
}

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

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

  // If space pressed, reset the state 
  if (CP_Input_KeyTriggered(KEY_SPACE))
  {
    CP_Engine_SetNextGameStateForced(init, update, NULL);
  }

  // If escape is pressed, end the program
  if (CP_Input_KeyTriggered(KEY_ESCAPE))
  {
    CP_Engine_Terminate();
  }
}

int main(void)
{
  // Set the initial game state
  CP_Engine_SetNextGameState(init, update, NULL);

  // Run the program
  CP_Engine_Run();    
}

See Also

Personal tools
Namespaces

Variants
Actions
Navigation
NameSpaces:>
Tools
Dynamic:>