Formatting review and examples review
This commit is contained in:
parent
4bceddd4de
commit
2f6230e366
16 changed files with 30 additions and 125 deletions
Binary file not shown.
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
@ -46,7 +46,7 @@ int main(void)
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
switch(currentScreen)
|
||||
switch (currentScreen)
|
||||
{
|
||||
case LOGO:
|
||||
{
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/*******************************************************************************************
|
||||
*
|
||||
* raylib [core] example - Gamepad information
|
||||
*
|
||||
* NOTE: This example requires a Gamepad connected to the system
|
||||
* Check raylib.h for buttons configuration
|
||||
*
|
||||
* Example originally created with raylib 4.6, last time updated with raylib 4.6
|
||||
*
|
||||
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
|
||||
* BSD-like license that allows static linking with closed source software
|
||||
*
|
||||
* Copyright (c) 2013-2024 Ramon Santamaria (@raysan5)
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
// Program main entry point
|
||||
//------------------------------------------------------------------------------------
|
||||
int main(void)
|
||||
{
|
||||
// Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
const int screenWidth = 800;
|
||||
const int screenHeight = 450;
|
||||
|
||||
SetConfigFlags(FLAG_MSAA_4X_HINT); // Set MSAA 4X hint before windows creation
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - gamepad information");
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
// Main game loop
|
||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
// TODO: Update your variables here
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
BeginDrawing();
|
||||
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
for (int i = 0, y = 5; i < 4; i++) // MAX_GAMEPADS = 4
|
||||
{
|
||||
if (IsGamepadAvailable(i))
|
||||
{
|
||||
DrawText(TextFormat("Gamepad name: %s", GetGamepadName(i)), 10, y, 10, BLACK);
|
||||
y += 11;
|
||||
DrawText(TextFormat("\tAxis count: %d", GetGamepadAxisCount(i)), 10, y, 10, BLACK);
|
||||
y += 11;
|
||||
|
||||
for (int axis = 0; axis < GetGamepadAxisCount(i); axis++)
|
||||
{
|
||||
DrawText(TextFormat("\tAxis %d = %f", axis, GetGamepadAxisMovement(i, axis)), 10, y, 10, BLACK);
|
||||
y += 11;
|
||||
}
|
||||
|
||||
for (int button = 0; button < 32; button++)
|
||||
{
|
||||
DrawText(TextFormat("\tButton %d = %d", button, IsGamepadButtonDown(i, button)), 10, y, 10, BLACK);
|
||||
y += 11;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawFPS(GetScreenWidth() - 100, 100);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
// De-Initialization
|
||||
//--------------------------------------------------------------------------------------
|
||||
CloseWindow(); // Close window and OpenGL context
|
||||
//--------------------------------------------------------------------------------------
|
||||
}
|
|
@ -42,7 +42,7 @@ int main(void)
|
|||
// Get the touch point count ( how many fingers are touching the screen )
|
||||
int tCount = GetTouchPointCount();
|
||||
// Clamp touch points available ( set the maximum touch points allowed )
|
||||
if(tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
||||
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
||||
// Get touch points positions
|
||||
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -115,26 +115,10 @@ int main(void)
|
|||
// Move player according to pressed button
|
||||
switch (pressedButton)
|
||||
{
|
||||
case BUTTON_UP:
|
||||
{
|
||||
playerPosition.y -= playerSpeed*GetFrameTime();
|
||||
break;
|
||||
}
|
||||
case BUTTON_LEFT:
|
||||
{
|
||||
playerPosition.x -= playerSpeed*GetFrameTime();
|
||||
break;
|
||||
}
|
||||
case BUTTON_RIGHT:
|
||||
{
|
||||
playerPosition.x += playerSpeed*GetFrameTime();
|
||||
break;
|
||||
}
|
||||
case BUTTON_DOWN:
|
||||
{
|
||||
playerPosition.y += playerSpeed*GetFrameTime();
|
||||
break;
|
||||
}
|
||||
case BUTTON_UP: playerPosition.y -= playerSpeed*GetFrameTime(); break;
|
||||
case BUTTON_LEFT: playerPosition.x -= playerSpeed*GetFrameTime(); break;
|
||||
case BUTTON_RIGHT: playerPosition.x += playerSpeed*GetFrameTime(); break;
|
||||
case BUTTON_DOWN: playerPosition.y += playerSpeed*GetFrameTime(); break;
|
||||
default: break;
|
||||
};
|
||||
|
||||
|
|
|
@ -174,7 +174,6 @@ static void DrawTextCenterKeyHelp(const char *key, const char *text, int posX, i
|
|||
int pressSize = MeasureText("Press", fontSize);
|
||||
int keySize = MeasureText(key, fontSize);
|
||||
int textSize = MeasureText(text, fontSize);
|
||||
int totalSize = pressSize + 2*spaceSize + keySize + 2*spaceSize + textSize;
|
||||
int textSizeCurrent = 0;
|
||||
|
||||
DrawText("Press", posX, posY, fontSize, color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue