mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-14 18:35:31 +00:00
REVIEWED: examples: Replace TABS and Remove trailing spaces
This commit is contained in:
@@ -64,7 +64,7 @@ int main(void)
|
||||
|
||||
// Encode data to Base64 string (includes NULL terminator), memory must be MemFree()
|
||||
base64Text = EncodeDataBase64((unsigned char *)textInput, textInputLen, &base64TextSize);
|
||||
|
||||
|
||||
hashCRC32 = ComputeCRC32((unsigned char *)textInput, textInputLen); // Compute CRC32 hash code (4 bytes)
|
||||
hashMD5 = ComputeMD5((unsigned char *)textInput, textInputLen); // Compute MD5 hash code, returns static int[4] (16 bytes)
|
||||
hashSHA1 = ComputeSHA1((unsigned char *)textInput, textInputLen); // Compute SHA1 hash code, returns static int[5] (20 bytes)
|
||||
|
||||
@@ -59,7 +59,7 @@ int main(void)
|
||||
// GetFrameTime() returns the time it took to draw the last frame, in seconds (usually called delta time)
|
||||
// Uses the delta time to make the circle look like it's moving at a "consistent" speed regardless of FPS
|
||||
|
||||
// Multiply by 6.0 (an arbitrary value) in order to make the speed
|
||||
// Multiply by 6.0 (an arbitrary value) in order to make the speed
|
||||
// visually closer to the other circle (at 60 fps), for comparison
|
||||
deltaCircle.x += GetFrameTime()*6.0f*speed;
|
||||
// This circle can move faster or slower visually depending on the FPS
|
||||
@@ -68,7 +68,7 @@ int main(void)
|
||||
// If either circle is off the screen, reset it back to the start
|
||||
if (deltaCircle.x > screenWidth) deltaCircle.x = 0;
|
||||
if (frameCircle.x > screenWidth) frameCircle.x = 0;
|
||||
|
||||
|
||||
// Reset both circles positions
|
||||
if (IsKeyPressed(KEY_R))
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
// Simple example for decoding input as actions, allowing remapping of input to different keys or gamepad buttons
|
||||
// For example instead of using `IsKeyDown(KEY_LEFT)`, you can use `IsActionDown(ACTION_LEFT)`
|
||||
// which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys
|
||||
// which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef struct ActionInput {
|
||||
// Global Variables Definition
|
||||
//----------------------------------------------------------------------------------
|
||||
static int gamepadIndex = 0; // Gamepad default index
|
||||
static ActionInput actionInputs[MAX_ACTION] = { 0 };
|
||||
static ActionInput actionInputs[MAX_ACTION] = { 0 };
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
@@ -67,15 +67,15 @@ int main(void)
|
||||
const int screenHeight = 450;
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - input actions");
|
||||
|
||||
// Set default actions
|
||||
|
||||
// Set default actions
|
||||
char actionSet = 0;
|
||||
SetActionsDefault();
|
||||
bool releaseAction = false;
|
||||
|
||||
Vector2 position = (Vector2){ 400.0f, 200.0f };
|
||||
Vector2 size = (Vector2){ 40.0f, 40.0f };
|
||||
|
||||
|
||||
SetTargetFPS(60);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
@@ -85,7 +85,7 @@ int main(void)
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
gamepadIndex = 0; // Set gamepad being checked
|
||||
|
||||
|
||||
if (IsActionDown(ACTION_UP)) position.y -= 2;
|
||||
if (IsActionDown(ACTION_DOWN)) position.y += 2;
|
||||
if (IsActionDown(ACTION_LEFT)) position.x -= 2;
|
||||
@@ -95,12 +95,12 @@ int main(void)
|
||||
position.x = (screenWidth-size.x)/2;
|
||||
position.y = (screenHeight-size.y)/2;
|
||||
}
|
||||
|
||||
|
||||
// Register release action for one frame
|
||||
releaseAction = false;
|
||||
if (IsActionReleased(ACTION_FIRE)) releaseAction = true;
|
||||
|
||||
// Switch control scheme by pressing TAB
|
||||
// Switch control scheme by pressing TAB
|
||||
if (IsKeyPressed(KEY_TAB))
|
||||
{
|
||||
actionSet = !actionSet;
|
||||
@@ -116,7 +116,7 @@ int main(void)
|
||||
ClearBackground(GRAY);
|
||||
|
||||
DrawRectangleV(position, size, releaseAction? BLUE : RED);
|
||||
|
||||
|
||||
DrawText((actionSet == 0)? "Current input set: WASD (default)" : "Current input set: Cursor", 10, 10, 20, WHITE);
|
||||
DrawText("Use TAB key to toggles Actions keyset", 10, 50, 20, GREEN);
|
||||
|
||||
@@ -140,9 +140,9 @@ int main(void)
|
||||
static bool IsActionPressed(int action)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
||||
if (action < MAX_ACTION) result = (IsKeyPressed(actionInputs[action].key) || IsGamepadButtonPressed(gamepadIndex, actionInputs[action].button));
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -151,20 +151,20 @@ static bool IsActionPressed(int action)
|
||||
static bool IsActionReleased(int action)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
||||
if (action < MAX_ACTION) result = (IsKeyReleased(actionInputs[action].key) || IsGamepadButtonReleased(gamepadIndex, actionInputs[action].button));
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Check action key/button down
|
||||
// NOTE: Combines key down and gamepad button down in one action
|
||||
static bool IsActionDown(int action)
|
||||
static bool IsActionDown(int action)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
||||
if (action < MAX_ACTION) result = (IsKeyDown(actionInputs[action].key) || IsGamepadButtonDown(gamepadIndex, actionInputs[action].button));
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ int main(void)
|
||||
const float rightStickDeadzoneY = 0.1f;
|
||||
const float leftTriggerDeadzone = -0.9f;
|
||||
const float rightTriggerDeadzone = -0.9f;
|
||||
|
||||
|
||||
Rectangle vibrateButton = { 0 };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
@@ -97,7 +97,7 @@ int main(void)
|
||||
if (leftTrigger < leftTriggerDeadzone) leftTrigger = -1.0f;
|
||||
if (rightTrigger < rightTriggerDeadzone) rightTrigger = -1.0f;
|
||||
|
||||
if ((TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1) ||
|
||||
if ((TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_1) > -1) ||
|
||||
(TextFindIndex(TextToLower(GetGamepadName(gamepad)), XBOX_ALIAS_2) > -1))
|
||||
{
|
||||
DrawTexture(texXboxPad, 0, 0, DARKGRAY);
|
||||
|
||||
@@ -118,6 +118,6 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* Example originally created with raylib 5.0, last time updated with raylib 5.0
|
||||
*
|
||||
* Example contributed by GreenSnakeLinux (@GreenSnakeLinux),
|
||||
* Example contributed by GreenSnakeLinux (@GreenSnakeLinux),
|
||||
* reviewed by Ramon Santamaria (@raysan5), oblerion (@oblerion) and danilwhale (@danilwhale)
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
@@ -86,7 +86,7 @@ int main(void)
|
||||
pressedButton = BUTTON_NONE;
|
||||
|
||||
// Make sure user is pressing left mouse button if they're from desktop
|
||||
if ((GetTouchPointCount() > 0) ||
|
||||
if ((GetTouchPointCount() > 0) ||
|
||||
((GetTouchPointCount() == 0) && IsMouseButtonDown(MOUSE_BUTTON_LEFT)))
|
||||
{
|
||||
// Find nearest D-Pad button to the input position
|
||||
@@ -113,7 +113,7 @@ int main(void)
|
||||
default: break;
|
||||
};
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Draw
|
||||
//--------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
@@ -66,25 +66,25 @@ int main(void)
|
||||
for (int i = 0; i < monitorCount; i++)
|
||||
{
|
||||
monitors[i] = (MonitorInfo){
|
||||
GetMonitorPosition(i),
|
||||
GetMonitorName(i),
|
||||
GetMonitorPosition(i),
|
||||
GetMonitorName(i),
|
||||
GetMonitorWidth(i),
|
||||
GetMonitorHeight(i),
|
||||
GetMonitorPhysicalWidth(i),
|
||||
GetMonitorPhysicalHeight(i),
|
||||
GetMonitorRefreshRate(i)
|
||||
};
|
||||
|
||||
|
||||
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = -(int)monitors[i].position.x;
|
||||
|
||||
const int width = (int)monitors[i].position.x + monitors[i].width;
|
||||
const int height = (int)monitors[i].position.y + monitors[i].height;
|
||||
|
||||
|
||||
if (maxWidth < width) maxWidth = width;
|
||||
if (maxHeight < height) maxHeight = height;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KEY_ENTER) && (monitorCount > 1))
|
||||
if (IsKeyPressed(KEY_ENTER) && (monitorCount > 1))
|
||||
{
|
||||
currentMonitorIndex += 1;
|
||||
|
||||
@@ -95,8 +95,8 @@ int main(void)
|
||||
}
|
||||
else currentMonitorIndex = GetCurrentMonitor(); // Get currentMonitorIndex if manually moved
|
||||
|
||||
float monitorScale = 0.6f;
|
||||
|
||||
float monitorScale = 0.6f;
|
||||
|
||||
if (maxHeight > (maxWidth + monitorOffsetX)) monitorScale *= ((float)screenHeight/(float)maxHeight);
|
||||
else monitorScale *= ((float)screenWidth/(float)(maxWidth + monitorOffsetX));
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -125,9 +125,9 @@ int main(void)
|
||||
// Draw monitor name and information inside the rectangle
|
||||
DrawText(TextFormat("[%i] %s", i, monitors[i].name), (int)rec.x + 10, (int)rec.y + (int)(100*monitorScale), (int)(120*monitorScale), BLUE);
|
||||
DrawText(
|
||||
TextFormat("Resolution: [%ipx x %ipx]\nRefreshRate: [%ihz]\nPhysical Size: [%imm x %imm]\nPosition: %3.0f x %3.0f",
|
||||
monitors[i].width,
|
||||
monitors[i].height,
|
||||
TextFormat("Resolution: [%ipx x %ipx]\nRefreshRate: [%ihz]\nPhysical Size: [%imm x %imm]\nPosition: %3.0f x %3.0f",
|
||||
monitors[i].width,
|
||||
monitors[i].height,
|
||||
monitors[i].refreshRate,
|
||||
monitors[i].physicalWidth,
|
||||
monitors[i].physicalHeight,
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#define MAX_UNDO_STATES 26 // Maximum undo states supported for the ring buffer
|
||||
|
||||
#define GRID_CELL_SIZE 24
|
||||
#define GRID_CELL_SIZE 24
|
||||
#define MAX_GRID_CELLS_X 30
|
||||
#define MAX_GRID_CELLS_Y 13
|
||||
|
||||
@@ -57,7 +57,7 @@ int main(void)
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
|
||||
// We have multiple options to implement an Undo/Redo system
|
||||
// Probably the most professional one is using the Command pattern to
|
||||
// define Actions and store those actions into an array as the events happen,
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
// For itteration purposes and teaching example
|
||||
#define RESOLUTION_COUNT 4
|
||||
|
||||
enum ViewportType
|
||||
enum ViewportType
|
||||
{
|
||||
// Only upscale, useful for pixel art
|
||||
KEEP_ASPECT_INTEGER,
|
||||
@@ -113,7 +113,7 @@ int main(void)
|
||||
}
|
||||
Vector2 mousePosition = GetMousePosition();
|
||||
bool mousePressed = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||
|
||||
|
||||
// Check buttons and rescale
|
||||
if (CheckCollisionPointRec(mousePosition, decreaseResolutionButton) && mousePressed){
|
||||
resolutionIndex = (resolutionIndex + RESOLUTION_COUNT - 1) % RESOLUTION_COUNT;
|
||||
|
||||
Reference in New Issue
Block a user