GSDP:GAM100/CProcessing/CP Math Sq()
From Inside
< GSDP:GAM100 | CProcessing
CP_Math_Sq()
Description
Takes in a float and returns its' squared value.
Parameters
CP_Math_Sq(float value)
- value - (float) The value to square.
Example
void square_init()
{
CP_Font_Set(CP_Font_GetDefault(), 50);
CP_Settings_Fill(CP_Color_Create(0, 0, 0, 255));
CP_Text_SetAlignment(CP_ALIGN_H_CENTER, CP_ALIGN_V_BOTTOM);
}
float random_value = 0.0f;
float time_elapsed = 1.5;
void square_update()
{
CP_Settings_Background(CP_Color_Create(255, 255, 255, 255));
if (time_elapsed >= 1.5f)
{
random_value = CP_Random_RangeFloat(0.0f, 100.0f);
time_elapsed = 0.0f;
}
else
time_elapsed += dt();
char num_string[128] = { 0 };
sprintf_s(num_string, 128, "The square of %.2f is %.2f", random_value, sq(random_value));
CP_Font_DrawTextBox(num_string, 0, CP_System_GetWindowHeight() / 2, CP_System_GetWindowWidth());
}
Related
- Main Page
- CP_Math_ClampFloat()
- CP_Math_ClampInt()
- CP_Math_LerpFloat()
- CP_Math_LerpInt()
- CP_Math_Degrees()
- CP_Math_Radians()
- CP_Font_Set()
- CP_Font_GetDefault()
- CP_Settings_Fill()
- CP_Color_Create()
- CP_Text_SetAlignment()
- CP_Settings_Background()
- CP_Font_DrawTextBox()
- CP_System_GetWindowWidth()
- CP_System_GetWindowHeight()