Watch
2
0
Fork
You've already forked raylib-cs
0

Improved XML comments for consistency, fixed spacing and formatting across examples, added new resources to resources.LICENSE.

This commit is contained in:
Meatcorps 2026-05-22 10:07:42 +02:00
commit cb77e4f195
8 changed files with 113 additions and 63 deletions

View file

@ -1,6 +1,3 @@
using System.Numerics;
namespace Examples.Core;
/******************************************************************************************* /*******************************************************************************************
* *
* raylib [core] example - delta time * raylib [core] example - delta time
@ -18,6 +15,10 @@ namespace Examples.Core;
* *
********************************************************************************************/ ********************************************************************************************/
using System.Numerics;
namespace Examples.Core;
using static Raylib_cs.Raylib; using static Raylib_cs.Raylib;
public class DeltaTime public class DeltaTime

View file

@ -90,7 +90,7 @@ public class InputGamepad
string gamepadName = GetGamepadName_(gamepad); string gamepadName = GetGamepadName_(gamepad);
DrawText($"GP{gamepad}: {gamepadName}", 10, 10, 10, Color.Black); DrawText($"GP{gamepad}: {gamepadName}", 10, 10, 10, Color.Black);
if (gamepadName.Contains(XBOX_ALIAS_1, StringComparison.OrdinalIgnoreCase)|| if (gamepadName.Contains(XBOX_ALIAS_1, StringComparison.OrdinalIgnoreCase) ||
gamepadName.Contains(XBOX_ALIAS_2, StringComparison.OrdinalIgnoreCase)) gamepadName.Contains(XBOX_ALIAS_2, StringComparison.OrdinalIgnoreCase))
{ {
DrawTexture(texXboxPad, 0, 0, Color.DarkGray); DrawTexture(texXboxPad, 0, 0, Color.DarkGray);

View file

@ -32,23 +32,23 @@ public class InputGesturesTestBed
public static int Main() public static int Main()
{ {
// Initialization // Initialization
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
const int screenWidth = 800; const int screenWidth = 800;
const int screenHeight = 450; const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed"); InitWindow(screenWidth, screenHeight, "raylib [core] example - input gestures testbed");
Vector2 messagePosition = new Vector2( 160, 7 ); Vector2 messagePosition = new Vector2(160, 7);
// Last gesture variables definitions // Last gesture variables definitions
Gesture lastGesture = 0; Gesture lastGesture = 0;
Vector2 lastGesturePosition = new Vector2( 165, 130 ); Vector2 lastGesturePosition = new Vector2(165, 130);
// Gesture log variables definitions // Gesture log variables definitions
// NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures // NOTE: The gesture log uses an array (as an inverted circular queue) to store the performed gestures
string[] gestureLog = new string[GESTURE_LOG_SIZE + 1]; string[] gestureLog = new string[GESTURE_LOG_SIZE + 1];
for (int i= 0; i < GESTURE_LOG_SIZE; i++) for (int i = 0; i < GESTURE_LOG_SIZE; i++)
{ {
gestureLog[i] = new string(new char[12]); gestureLog[i] = new string(new char[12]);
} }
@ -64,16 +64,16 @@ public class InputGesturesTestBed
// - 3 hides repeated events and hide hold events // - 3 hides repeated events and hide hold events
int logMode = 1; int logMode = 1;
Color gestureColor = new Color(0, 0, 0, 255 ); Color gestureColor = new Color(0, 0, 0, 255);
Rectangle logButton1 = new Rectangle( 53, 7, 48, 26 ); Rectangle logButton1 = new Rectangle(53, 7, 48, 26);
Rectangle logButton2 = new Rectangle( 108, 7, 36, 26 ); Rectangle logButton2 = new Rectangle(108, 7, 36, 26);
Vector2 gestureLogPosition = new Vector2( 10, 10 ); Vector2 gestureLogPosition = new Vector2(10, 10);
// Protractor variables definitions // Protractor variables definitions
float angleLength = 90.0f; float angleLength = 90.0f;
float currentAngleDegrees = 0.0f; float currentAngleDegrees = 0.0f;
Vector2 finalVector = new Vector2( 0.0f, 0.0f ); Vector2 finalVector = new Vector2(0.0f, 0.0f);
Vector2 protractorPosition = new Vector2( 266.0f, 315.0f ); Vector2 protractorPosition = new Vector2(266.0f, 315.0f);
SetTargetFPS(60); // Set our game to run at 60 frames-per-second SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -103,20 +103,36 @@ public class InputGesturesTestBed
{ {
switch (logMode) switch (logMode)
{ {
case 3: logMode = 2; break; case 3:
case 2: logMode = 3; break; logMode = 2;
case 1: logMode = 0; break; break;
default: logMode = 1; break; case 2:
logMode = 3;
break;
case 1:
logMode = 0;
break;
default:
logMode = 1;
break;
} }
} }
else if (CheckCollisionPointRec(GetMousePosition(), logButton2)) else if (CheckCollisionPointRec(GetMousePosition(), logButton2))
{ {
switch (logMode) switch (logMode)
{ {
case 3: logMode = 1; break; case 3:
case 2: logMode = 0; break; logMode = 1;
case 1: logMode = 3; break; break;
default: logMode = 2; break; case 2:
logMode = 0;
break;
case 1:
logMode = 3;
break;
default:
logMode = 2;
break;
} }
} }
} }
@ -397,38 +413,62 @@ public class InputGesturesTestBed
{ {
switch (gesture) switch (gesture)
{ {
case 0: return "None"; case 0:
case 1: return "Tap"; return "None";
case 2: return "Double Tap"; case 1:
case 4: return "Hold"; return "Tap";
case 8: return "Drag"; case 2:
case 16: return "Swipe Right"; return "Double Tap";
case 32: return "Swipe Left"; case 4:
case 64: return "Swipe Up"; return "Hold";
case 128: return "Swipe Down"; case 8:
case 256: return "Pinch In"; return "Drag";
case 512: return "Pinch Out"; case 16:
default: return "Unknown"; return "Swipe Right";
case 32:
return "Swipe Left";
case 64:
return "Swipe Up";
case 128:
return "Swipe Down";
case 256:
return "Pinch In";
case 512:
return "Pinch Out";
default:
return "Unknown";
} }
} }
// Get color for gesture value // Get color for gesture value
static Color GetGestureColor(int gesture) static Color GetGestureColor(int gesture)
{ {
switch (gesture) switch (gesture)
{ {
case 0: return Color.Black; case 0:
case 1: return Color.Blue; return Color.Black;
case 2: return Color.SkyBlue; case 1:
case 4: return Color.Black; return Color.Blue;
case 8: return Color.Lime; case 2:
case 16: return Color.Red; return Color.SkyBlue;
case 32: return Color.Red; case 4:
case 64: return Color.Red; return Color.Black;
case 128: return Color.Red; case 8:
case 256: return Color.Violet; return Color.Lime;
case 512: return Color.Orange; case 16:
default: return Color.Black; return Color.Red;
case 32:
return Color.Red;
case 64:
return Color.Red;
case 128:
return Color.Red;
case 256:
return Color.Violet;
case 512:
return Color.Orange;
default:
return Color.Black;
} }
} }
} }

View file

@ -28,7 +28,7 @@ public class InputMouseWheel
InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel"); InitWindow(screenWidth, screenHeight, "raylib [core] example - input mouse wheel");
int boxPositionY = screenHeight/2 - 40; int boxPositionY = screenHeight / 2 - 40;
int scrollSpeed = 4; // Scrolling speed in pixels int scrollSpeed = 4; // Scrolling speed in pixels
SetTargetFPS(60); SetTargetFPS(60);

View file

@ -122,9 +122,9 @@ public class InputVirtualControls
]; ];
int pressedButton = (int)PadButton.BUTTON_NONE; int pressedButton = (int)PadButton.BUTTON_NONE;
Vector2 inputPosition = new Vector2( 0, 0 ); Vector2 inputPosition = new Vector2(0, 0);
Vector2 playerPosition = new Vector2( (float)screenWidth / 2, (float)screenHeight / 2 ); Vector2 playerPosition = new Vector2((float)screenWidth / 2, (float)screenHeight / 2);
float playerSpeed = 75f; float playerSpeed = 75f;
SetTargetFPS(60); SetTargetFPS(60);
@ -168,11 +168,20 @@ public class InputVirtualControls
// Move player according to pressed button // Move player according to pressed button
switch ((PadButton)pressedButton) switch ((PadButton)pressedButton)
{ {
case PadButton.BUTTON_UP: playerPosition.Y -= playerSpeed * GetFrameTime(); break; case PadButton.BUTTON_UP:
case PadButton.BUTTON_LEFT: playerPosition.X -= playerSpeed * GetFrameTime(); break; playerPosition.Y -= playerSpeed * GetFrameTime();
case PadButton.BUTTON_RIGHT: playerPosition.X += playerSpeed * GetFrameTime(); break; break;
case PadButton.BUTTON_DOWN: playerPosition.Y += playerSpeed * GetFrameTime(); break; case PadButton.BUTTON_LEFT:
default: break; playerPosition.X -= playerSpeed * GetFrameTime();
break;
case PadButton.BUTTON_RIGHT:
playerPosition.X += playerSpeed * GetFrameTime();
break;
case PadButton.BUTTON_DOWN:
playerPosition.Y += playerSpeed * GetFrameTime();
break;
default:
break;
} }
; ;

View file

@ -21,7 +21,6 @@
********************************************************************************************/ ********************************************************************************************/
using System.Numerics; using System.Numerics;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib; using static Raylib_cs.Raylib;
namespace Examples.Models; namespace Examples.Models;
@ -67,11 +66,11 @@ public class LoadingGltf
if (IsKeyPressed(KeyboardKey.Right)) if (IsKeyPressed(KeyboardKey.Right))
{ {
animIndex = (animIndex + 1)%anims.Length; animIndex = (animIndex + 1) % anims.Length;
} }
else if (IsKeyPressed(KeyboardKey.Left)) else if (IsKeyPressed(KeyboardKey.Left))
{ {
animIndex = (animIndex + anims.Length - 1)%anims.Length; animIndex = (animIndex + anims.Length - 1) % anims.Length;
} }

View file

@ -55,6 +55,7 @@ models:
| models/barracks.obj,<br> models/barracks_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | | models/barracks.obj,<br> models/barracks_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
| models/church.obj,<br> models/church_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | | models/church.obj,<br> models/church_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
| models/watermill.obj,<br> models/watermill_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | | models/watermill.obj,<br> models/watermill_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - |
| greenman.glb, greenman_hat.glb, greenman_sword.glb, greenman_shield.glb | [@ip](https://github.com/ipzaur) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - |
images: images:
| resource | author | licence | notes | | resource | author | licence | notes |

View file

@ -477,7 +477,7 @@ public static unsafe partial class Rlgl
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial void SetPointSize(float size); public static partial void SetPointSize(float size);
/// <summary>Set the point drawing size</summary> /// <summary>Get the point drawing size</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlGetPointSize")] [LibraryImport(NativeLibName, EntryPoint = "rlGetPointSize")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial float GetPointSize(); public static partial float GetPointSize();
@ -594,12 +594,12 @@ public static unsafe partial class Rlgl
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial GlVersion GetVersion(); public static partial GlVersion GetVersion();
/// <summary>Get default framebuffer width</summary> /// <summary>Set current framebuffer width</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferWidth")] [LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferWidth")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int SetFramebufferWidth(int width); public static partial int SetFramebufferWidth(int width);
/// <summary>Get default framebuffer width</summary> /// <summary>Set current framebuffer height</summary>
[LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferHeight")] [LibraryImport(NativeLibName, EntryPoint = "rlSetFramebufferHeight")]
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
public static partial int SetFramebufferHeight(int height); public static partial int SetFramebufferHeight(int height);