Input - Polkm105/DesignPatternPractice GitHub Wiki
PARTIAL
This section contains all functions relating to CP_Sounds
Table Of Contents
- CP_Input_KeyTriggered
- CP_Input_KeyReleased
- CP_Input_KeyDown
- CP_Input_MouseTriggered
- CP_Input_MouseReleased
- CP_Input_MouseDown
- CP_Input_MouseMoved
- CP_Input_MouseClicked
- CP_Input_MouseDoubleClicked
- CP_Input_MouseDragged
- CP_Input_MouseWheel
- CP_Input_GetMouseX
- CP_Input_GetMouseY
- CP_Input_GetMousePreviousX
- CP_Input_GetMousePreviousY
- CP_Input_GetMouseDeltaX
- CP_Input_GetMouseDeltaY
- CP_Input_GetMouseWorldX
- CP_Input_GetMouseWorldY
- CP_Input_GamepadTriggered
- CP_Input_GamepadTriggeredAdvanced
- CP_Input_GamepadReleased
- CP_Input_GamepadReleasedAdvanced
- CP_Input_GamepadDown
- CP_Input_GamepadDownAdvanced
- CP_Input_GamepadRightTrigger
- CP_Input_GamepadRightTriggerAdvanced
- CP_Input_GamepadLeftTrigger
- CP_Input_GamepadLeftTriggerAdvanced
- CP_Input_GamepadRightStick
- CP_Input_GamepadRightStickAdvanced
- CP_Input_GamepadLeftStick
- CP_Input_GamepadLeftStickAdvanced
- CP_Input_GamepadConnected
- CP_Input_GamepadConnectedAdvanced
CP_Input_KeyTriggered
Returns TRUE if key was just pressed this frame, note this does not include being held down. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_KeyTriggered(CP_KEY keyCode);
Parameters
- keyCode - CP_KEY The key being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the spacebar is pressed
if (CP_Input_KeyTriggered(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If spacebar is being held
else if (CP_Input_KeyDown(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If spacebar was just released
else if (CP_Input_KeyReleased(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
CP_Input_KeyReleased
Returns TRUE if key was released this frame. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_KeyReleased(CP_KEY keyCode);
Parameters
- keyCode - CP_KEY The key being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the spacebar is pressed
if (CP_Input_KeyTriggered(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If spacebar is being held
else if (CP_Input_KeyDown(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If spacebar was just released
else if (CP_Input_KeyReleased(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
CP_Input_KeyDown
Returns TRUE if the key is down. Note: This is true on the first frame and any subsequent frames that the key may be held. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_KeyDown(CP_KEY keyCode);
Parameters
- keyCode - CP_KEY The key being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the spacebar is pressed
if (CP_Input_KeyTriggered(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If spacebar is being held
else if (CP_Input_KeyDown(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If spacebar was just released
else if (CP_Input_KeyReleased(KEY_SPACE))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
- CP_KEY
- CP_BOOL
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_KeyReleased
- CP_Input_KeyTriggered
CP_Input_MouseTriggered
Returns TRUE if the mouse button was pressed this frame, note does not return TRUE on being held down. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_MouseTriggered(CP_MOUSE button);
Parameters
- button - CP_MOUSE The mouse button being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the left mouse button is pressed
if (CP_Input_MouseTriggered(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If left mouse button is being held
else if (CP_Input_MouseDown(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If left mouse button was just released
else if (CP_Input_MouseReleased(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
- CP_MOUSE
- CP_BOOL
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_MouseDown
- CP_Input_MouseReleased
CP_Input_MouseReleased
Returns TRUE if mouse button was released this frame. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_MouseReleased(CP_MOUSE button);
Parameters
- button - CP_MOUSE The mouse button being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the left mouse button is pressed
if (CP_Input_MouseTriggered(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If left mouse button is being held
else if (CP_Input_MouseDown(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If left mouse button was just released
else if (CP_Input_MouseReleased(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
- CP_MOUSE
- CP_BOOL
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_MouseDown
- CP_Input_MouseTriggered
CP_Input_MouseDown
Returns TRUE if the mouse button is pressed. Note: This is true on the first frame and any subsequent frames the button remains pressed. Returns FALSE otherwise.
Function
CP_BOOL CP_Input_MouseDown(CP_MOUSE button);
Parameters
- button - CP_MOUSE The mouse button being checked.
Return
This function returns a CP_BOOL.
Example
void update(void)
{
// If this is the first frame the left mouse button is pressed
if (CP_Input_MouseTriggered(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 192, 203, 255));
}
// If left mouse button is being held
else if (CP_Input_MouseDown(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(25, 180, 220, 255));
}
// If left mouse button was just released
else if (CP_Input_MouseReleased(MOUSE_BUTTON_LEFT))
{
CP_Graphics_ClearBackground(CP_Color_Create(255, 128, 0, 255));
}
// Default state
else
{
CP_Graphics_ClearBackground(CP_Color_Create(0, 0, 0, 255));
}
}
Related
- CP_MOUSE
- CP_BOOL
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_MouseReleased
- CP_Input_MouseTriggered
CP_Input_MouseMoved
CP_Input_MouseClicked
CP_Input_MouseDoubleClicked
CP_Input_MouseDragged
CP_Input_MouseWheel
CP_Input_GetMouseX
This function returns the current horizontal coordinate of the mouse. This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMouseX(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Graphics_DrawLine(CP_Input_GetMouseX(), 20, CP_Input_GetMouseX(), 80);
}
Related
CP_Input_GetMouseY
This function returns the current vertical coordinate of the mouse. This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMouseY(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Graphics_DrawLine(20, CP_Input_GetMouseY(), 80, CP_Input_GetMouseY());
}
Related
CP_Input_GetMousePreviousX
The function CP_Input_GetMousePreviousX() always returns the previous horizontal coordinate of the mouse. This value will be the same as CP_Input_GetMouseX the previous frame. This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMousePreviousX(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Graphics_DrawLine(CP_Input_GetMouseX(), CP_Input_GetMouseY(), CP_Input_GetMousePreviousX(), CP_Input_GetMousePreviousY());
}
Related
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_GetMouseX
- CP_Input_GetMouseY
- CP_Input_GetMousePreviousY
- CP_Graphics_DrawLine
CP_Input_GetMousePreviousY
The function CP_Input_GetMousePreviousY() always returns the previous vertical coordinate of the mouse. This value will be the same as CP_Input_GetMouseY the previous frame. This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMousePreviousY(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Graphics_DrawLine(CP_Input_GetMouseX(), CP_Input_GetMouseY(), CP_Input_GetMousePreviousX(), CP_Input_GetMousePreviousY());
}
Related
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_GetMouseX
- CP_Input_GetMouseY
- CP_Input_GetMousePreviousX
- CP_Graphics_DrawLine
CP_Input_GetMouseDeltaX
CP_Input_GetMouseDeltaY
CP_Input_GetMouseWorldX
The function CP_Input_GetMouseWorldX() always returns the current horizontal coordinate of the mouse in world space. This means that the mouse position will be translated by any transformation functions called (CP_Settings_Translate, CP_Settings_Scale, CP_Settings_Rotate). This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMouseWorldX(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Settings_Translate(CP_Input_GetMouseX(), CP_Input_GetMouseY());
CP_Graphics_DrawLine(0, 0, CP_Input_GetMouseWorldX(), CP_Input_GetMouseWorldY());
}
Related
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_GetMouseX
- CP_Input_GetMouseY
- CP_Input_GetMouseWorldY
- CP_Settings_Translate
- CP_Graphics_DrawLine
CP_Input_GetMouseWorldY
The function CP_Input_GetMouseWorldY() always returns the current vertical coordinate of the mouse in world space. This means that the mouse position will be translated by any transformation functions called (CP_Settings_Translate, CP_Settings_Scale, CP_Settings_Rotate). This will track the position of the mouse anywhere on the screen, even if the window is in the background.
Function
float CP_Input_GetMouseWorldX(void);
Parameters
This function has no parameters.
Return
float
Example
void draw()
{
CP_Graphics_ClearBackground(CP_Color_Create(200, 200, 200, 255));
CP_Settings_Translate(CP_Input_GetMouseX(), CP_Input_GetMouseY());
CP_Graphics_DrawLine(0, 0, CP_Input_GetMouseWorldX(), CP_Input_GetMouseWorldY());
}
Related
- CP_Graphics_ClearBackground
- CP_Color_Create
- CP_Input_GetMouseX
- CP_Input_GetMouseY
- CP_Input_GetMouseWorldX
- CP_Settings_Translate
- CP_Graphics_DrawLine