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

chore: clean up linter warnings

This commit is contained in:
tiger tiger tiger 2026-07-29 19:58:47 +02:00
commit dfc34997bc
No known key found for this signature in database
217 changed files with 1863 additions and 1077 deletions

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public unsafe partial class AmpEnvelope : IExample
@ -89,9 +85,15 @@ public unsafe partial class AmpEnvelope : IExample
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.Space)) env.State = ADSRState.Attack;
if (IsKeyPressed(KeyboardKey.Space))
{
env.State = ADSRState.Attack;
}
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle)) env.State = ADSRState.Release;
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle))
{
env.State = ADSRState.Release;
}
if (IsAudioStreamProcessed(stream))
{
@ -106,7 +108,11 @@ public unsafe partial class AmpEnvelope : IExample
else
{
// Clear buffer if silent to avoid looping noise
for (int i = 0; i < BUFFER_SIZE; i++) buffer[i] = 0;
for (int i = 0; i < BUFFER_SIZE; i++)
{
buffer[i] = 0;
}
audioTime = 0.0f;
}
@ -116,7 +122,10 @@ public unsafe partial class AmpEnvelope : IExample
}
}
if (!IsAudioStreamPlaying(stream)) PlayAudioStream(stream);
if (!IsAudioStreamPlaying(stream))
{
PlayAudioStream(stream);
}
//----------------------------------------------------------------------------------
// Draw

View file

@ -15,10 +15,8 @@
*
********************************************************************************************/
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -60,7 +58,10 @@ public unsafe partial class MixedProcessor : IExample
}
// Moving history to the left
for (int i = 0; i < 399; i++) averageVolume[i] = averageVolume[i + 1];
for (int i = 0; i < 399; i++)
{
averageVolume[i] = averageVolume[i + 1];
}
averageVolume[399] = average; // Adding last average value
}
@ -88,13 +89,30 @@ public unsafe partial class MixedProcessor : IExample
// Modify processing variables
//----------------------------------------------------------------------------------
if (IsKeyPressed(KeyboardKey.Left)) exponent -= 0.05f;
if (IsKeyPressed(KeyboardKey.Right)) exponent += 0.05f;
if (IsKeyPressed(KeyboardKey.Left))
{
exponent -= 0.05f;
}
if (exponent <= 0.5f) exponent = 0.5f;
if (exponent >= 3.0f) exponent = 3.0f;
if (IsKeyPressed(KeyboardKey.Right))
{
exponent += 0.05f;
}
if (IsKeyPressed(KeyboardKey.Space)) PlaySound(sound);
if (exponent <= 0.5f)
{
exponent = 0.5f;
}
if (exponent >= 3.0f)
{
exponent = 3.0f;
}
if (IsKeyPressed(KeyboardKey.Space))
{
PlaySound(sound);
}
// Draw
//----------------------------------------------------------------------------------

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class ModulePlaying : IExample

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class MusicStreamDemo : IExample

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public unsafe partial class RawStream : IExample
@ -71,26 +67,40 @@ public unsafe partial class RawStream : IExample
if (IsKeyDown(KeyboardKey.Up))
{
newSineFrequency += 10;
if (newSineFrequency > 12500) newSineFrequency = 12500;
if (newSineFrequency > 12500)
{
newSineFrequency = 12500;
}
}
if (IsKeyDown(KeyboardKey.Down))
{
newSineFrequency -= 10;
if (newSineFrequency < 20) newSineFrequency = 20;
if (newSineFrequency < 20)
{
newSineFrequency = 20;
}
}
if (IsKeyDown(KeyboardKey.Left))
{
pan -= 0.01f;
if (pan < -1.0f) pan = -1.0f;
if (pan < -1.0f)
{
pan = -1.0f;
}
SetAudioStreamPan(stream, pan);
}
if (IsKeyDown(KeyboardKey.Right))
{
pan += 0.01f;
if (pan > 1.0f) pan = 1.0f;
if (pan > 1.0f)
{
pan = 1.0f;
}
SetAudioStreamPan(stream, pan);
}

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundLoading : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundMulti : IExample
@ -42,7 +40,10 @@ public partial class SoundMulti : IExample
soundArray[0] = LoadSound("resources/audio/sound.wav");
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
for (int i = 1; i < MAX_SOUNDS; i++)
{
soundArray[i] = LoadSoundAlias(soundArray[0]);
}
currentSound = 0; // Set the sound list to the start
}
@ -57,7 +58,10 @@ public partial class SoundMulti : IExample
currentSound++; // Increment the sound slot
// If the sound slot is out of bounds, go back to 0
if (currentSound >= MAX_SOUNDS) currentSound = 0;
if (currentSound >= MAX_SOUNDS)
{
currentSound = 0;
}
// NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot
@ -78,7 +82,11 @@ public partial class SoundMulti : IExample
public void Unload()
{
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
for (int i = 1; i < MAX_SOUNDS; i++)
{
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
}
UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
public partial class SoundPositioning : IExample
@ -67,7 +63,10 @@ public partial class SoundPositioning : IExample
SetSoundPosition(camera, sound, spherePos, 1.0f);
if (!IsSoundPlaying(sound)) PlaySound(sound);
if (!IsSoundPlaying(sound))
{
PlaySound(sound);
}
//----------------------------------------------------------------------------------
// Draw
@ -112,7 +111,10 @@ public partial class SoundPositioning : IExample
// Reduce volume for sounds behind the listener
float dotProduct = Vector3.Dot(forward, normalizedDirection);
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct * 0.5f);
if (dotProduct < 0.0f)
{
attenuation *= (1.0f + dotProduct * 0.5f);
}
// Set stereo panning based on sound position relative to listener
float pan = 0.5f + 0.5f * Vector3.Dot(normalizedDirection, right);

View file

@ -20,11 +20,8 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -105,31 +102,61 @@ public unsafe partial class StreamCallback : IExample
if (IsKeyDown(KeyboardKey.Up))
{
newWaveFrequency += 10;
if (newWaveFrequency > 12500) newWaveFrequency = 12500;
if (newWaveFrequency > 12500)
{
newWaveFrequency = 12500;
}
}
if (IsKeyDown(KeyboardKey.Down))
{
newWaveFrequency -= 10;
if (newWaveFrequency < 20) newWaveFrequency = 20;
if (newWaveFrequency < 20)
{
newWaveFrequency = 20;
}
}
if (IsKeyPressed(KeyboardKey.Left))
{
if (waveType == WaveType.Sine) waveType = WaveType.Sawtooth;
else if (waveType == WaveType.Square) waveType = WaveType.Sine;
else if (waveType == WaveType.Triangle) waveType = WaveType.Square;
else waveType = WaveType.Triangle;
if (waveType == WaveType.Sine)
{
waveType = WaveType.Sawtooth;
}
else if (waveType == WaveType.Square)
{
waveType = WaveType.Sine;
}
else if (waveType == WaveType.Triangle)
{
waveType = WaveType.Square;
}
else
{
waveType = WaveType.Triangle;
}
SetWaveCallback();
}
if (IsKeyPressed(KeyboardKey.Right))
{
if (waveType == WaveType.Sine) waveType = WaveType.Square;
else if (waveType == WaveType.Square) waveType = WaveType.Triangle;
else if (waveType == WaveType.Triangle) waveType = WaveType.Sawtooth;
else waveType = WaveType.Sine;
if (waveType == WaveType.Sine)
{
waveType = WaveType.Square;
}
else if (waveType == WaveType.Square)
{
waveType = WaveType.Triangle;
}
else if (waveType == WaveType.Triangle)
{
waveType = WaveType.Sawtooth;
}
else
{
waveType = WaveType.Sine;
}
SetWaveCallback();
}
@ -197,8 +224,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -222,8 +256,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -247,8 +288,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
@ -272,8 +320,15 @@ public unsafe partial class StreamCallback : IExample
}
// Save the synthesized samples for later drawing
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
for (int i = 0; i < SAMPLE_RATE - fc; i++)
{
buffer[i] = buffer[i + fc];
}
for (int i = 0; i < fc; i++)
{
buffer[SAMPLE_RATE - fc + i] = frames[i];
}
}
public static int Main()

View file

@ -15,7 +15,6 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Audio;
@ -87,30 +86,51 @@ public unsafe partial class StreamEffects : IExample
{
pause = !pause;
if (pause) PauseMusicStream(music);
else ResumeMusicStream(music);
if (pause)
{
PauseMusicStream(music);
}
else
{
ResumeMusicStream(music);
}
}
// Add/Remove effect: lowpass filter
if (IsKeyPressed(KeyboardKey.F))
{
enableEffectLPF = !enableEffectLPF;
if (enableEffectLPF) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
if (enableEffectLPF)
{
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
}
else
{
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
}
}
// Add/Remove effect: delay
if (IsKeyPressed(KeyboardKey.D))
{
enableEffectDelay = !enableEffectDelay;
if (enableEffectDelay) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
if (enableEffectDelay)
{
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
}
else
{
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
}
}
// Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music) / GetMusicTimeLength(music);
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
if (timePlayed > 1.0f)
{
timePlayed = 1.0f; // Make sure time played is no longer than music
}
//----------------------------------------------------------------------------------
// Draw
@ -180,14 +200,20 @@ public unsafe partial class StreamEffects : IExample
float leftDelay = delay[delayReadIndex++]; // ERROR: Reading buffer -> WHY??? Maybe thread related???
float rightDelay = delay[delayReadIndex++];
if (delayReadIndex == delayBufferSize) delayReadIndex = 0;
if (delayReadIndex == delayBufferSize)
{
delayReadIndex = 0;
}
bufferData[i] = 0.5f * bufferData[i] + 0.5f * leftDelay;
bufferData[i + 1] = 0.5f * bufferData[i + 1] + 0.5f * rightDelay;
delay[delayWriteIndex++] = bufferData[i];
delay[delayWriteIndex++] = bufferData[i + 1];
if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0;
if (delayWriteIndex == delayBufferSize)
{
delayWriteIndex = 0;
}
}
}
}

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class AutomationEvents : IExample
@ -143,8 +139,16 @@ public partial class AutomationEvents : IExample
// Update player
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.Left)) player.Position.X -= PLAYER_HOR_SPD * deltaTime;
if (IsKeyDown(KeyboardKey.Right)) player.Position.X += PLAYER_HOR_SPD * deltaTime;
if (IsKeyDown(KeyboardKey.Left))
{
player.Position.X -= PLAYER_HOR_SPD * deltaTime;
}
if (IsKeyDown(KeyboardKey.Right))
{
player.Position.X += PLAYER_HOR_SPD * deltaTime;
}
if (IsKeyDown(KeyboardKey.Space) && player.CanJump)
{
player.Speed = -PLAYER_JUMP_SPD;
@ -173,7 +177,10 @@ public partial class AutomationEvents : IExample
player.Speed += GRAVITY * deltaTime;
player.CanJump = false;
}
else player.CanJump = true;
else
{
player.CanJump = true;
}
if (IsKeyPressed(KeyboardKey.R))
{
@ -224,8 +231,14 @@ public partial class AutomationEvents : IExample
// WARNING: On event replay, mouse-wheel internal value is set
camera.Zoom += ((float)GetMouseWheelMove() * 0.05f);
if (camera.Zoom > 3.0f) camera.Zoom = 3.0f;
else if (camera.Zoom < 0.25f) camera.Zoom = 0.25f;
if (camera.Zoom > 3.0f)
{
camera.Zoom = 3.0f;
}
else if (camera.Zoom < 0.25f)
{
camera.Zoom = 0.25f;
}
for (int i = 0; i < MAX_ENVIRONMENT_ELEMENTS; i++)
{
@ -239,10 +252,25 @@ public partial class AutomationEvents : IExample
Vector2 max = GetWorldToScreen2D(new Vector2(maxX, maxY), camera);
Vector2 min = GetWorldToScreen2D(new Vector2(minX, minY), camera);
if (max.X < screenWidth) camera.Offset.X = screenWidth - (max.X - (float)screenWidth / 2);
if (max.Y < screenHeight) camera.Offset.Y = screenHeight - (max.Y - (float)screenHeight / 2);
if (min.X > 0) camera.Offset.X = (float)screenWidth / 2 - min.X;
if (min.Y > 0) camera.Offset.Y = (float)screenHeight / 2 - min.Y;
if (max.X < screenWidth)
{
camera.Offset.X = screenWidth - (max.X - (float)screenWidth / 2);
}
if (max.Y < screenHeight)
{
camera.Offset.Y = screenHeight - (max.Y - (float)screenHeight / 2);
}
if (min.X > 0)
{
camera.Offset.X = (float)screenWidth / 2 - min.X;
}
if (min.Y > 0)
{
camera.Offset.Y = (float)screenHeight / 2 - min.Y;
}
//----------------------------------------------------------------------------------
// Events management
@ -287,8 +315,14 @@ public partial class AutomationEvents : IExample
}
}
if (eventRecording || eventPlaying) frameCounter++;
else frameCounter = 0;
if (eventRecording || eventPlaying)
{
frameCounter++;
}
else
{
frameCounter = 0;
}
//----------------------------------------------------------------------------------
// Draw
@ -329,7 +363,10 @@ public partial class AutomationEvents : IExample
DrawRectangleLines(10, 160, 290, 30, Fade(Color.Maroon, 0.8f));
DrawCircle(30, 175, 10, Color.Maroon);
if (((frameCounter / 15) % 2) == 1) DrawText($"RECORDING EVENTS... [{aelist.Count}]", 50, 170, 10, Color.Maroon);
if (((frameCounter / 15) % 2) == 1)
{
DrawText($"RECORDING EVENTS... [{aelist.Count}]", 50, 170, 10, Color.Maroon);
}
}
else if (eventPlaying)
{
@ -337,7 +374,10 @@ public partial class AutomationEvents : IExample
DrawRectangleLines(10, 160, 290, 30, Fade(Color.DarkGreen, 0.8f));
DrawTriangle(new Vector2(20, 155 + 10), new Vector2(20, 155 + 30), new Vector2(40, 155 + 20), Color.DarkGreen);
if (((frameCounter / 15) % 2) == 1) DrawText($"PLAYING RECORDED EVENTS... [{currentPlayFrame}]", 50, 170, 10, Color.DarkGreen);
if (((frameCounter / 15) % 2) == 1)
{
DrawText($"PLAYING RECORDED EVENTS... [{currentPlayFrame}]", 50, 170, 10, Color.DarkGreen);
}
}
EndDrawing();

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
internal enum GameScreen

View file

@ -26,11 +26,6 @@
*
********************************************************************************************/
using System.Numerics;
using System;
using System.Text;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class BasicWindow : IExample

View file

@ -13,10 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class Camera2dDemo : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Core;

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Core;

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class Camera3dFirstPerson : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Core;
@ -167,11 +164,17 @@ public partial class Camera3dFps : IExample
// `#define NORMALIZE_INPUT 0` above it (defined() tests definedness, not the value), so the
// diagonal-movement normalization is active.
// Slow down diagonal movement
if ((side != 0) && (forward != 0)) input = Vector2Normalize(input);
if ((side != 0) && (forward != 0))
{
input = Vector2Normalize(input);
}
float delta = GetFrameTime();
if (!body.IsGrounded) body.Velocity.Y -= GRAVITY * delta;
if (!body.IsGrounded)
{
body.Velocity.Y -= GRAVITY * delta;
}
if (body.IsGrounded && jumpPressed)
{
@ -196,7 +199,10 @@ public partial class Camera3dFps : IExample
Vector3 hvel = new Vector3(body.Velocity.X * decel, 0.0f, body.Velocity.Z * decel);
float hvelLength = Vector3Length(hvel); // Magnitude
if (hvelLength < (MAX_SPEED * 0.01f)) hvel = new Vector3(0, 0, 0);
if (hvelLength < (MAX_SPEED * 0.01f))
{
hvel = new Vector3(0, 0, 0);
}
// This is what creates strafing
float speed = Vector3DotProduct(hvel, body.Dir);

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class Camera3dFree : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class Camera3dMode : IExample

View file

@ -20,10 +20,7 @@
// using plain raylib drawing/input. Clipboard behaviour (cut/copy/paste and CTRL+X/C/V
// shortcuts) matches the original.
using System;
using System.Numerics;
using System.Text;
using static Raylib_cs.Raylib;
namespace Examples.Core;
@ -104,7 +101,10 @@ public partial class ClipboardText : IExample
{
// Paste text from clipboard
clipboardText = GetClipboardText_();
if (clipboardText != null) SetInputBuffer(clipboardText);
if (clipboardText != null)
{
SetInputBuffer(clipboardText);
}
}
if (btnClearPressed)
@ -127,12 +127,18 @@ public partial class ClipboardText : IExample
inputBuffer.Clear(); // Quick solution to clear text
}
if (IsKeyPressed(KeyboardKey.C)) SetClipboardText(inputBuffer.ToString());
if (IsKeyPressed(KeyboardKey.C))
{
SetClipboardText(inputBuffer.ToString());
}
if (IsKeyPressed(KeyboardKey.V))
{
clipboardText = GetClipboardText_();
if (clipboardText != null) SetInputBuffer(clipboardText);
if (clipboardText != null)
{
SetInputBuffer(clipboardText);
}
}
}
//----------------------------------------------------------------------------------
@ -148,7 +154,10 @@ public partial class ClipboardText : IExample
DrawText("[CTRL+X] - CUT | [CTRL+C] COPY | [CTRL+V] | PASTE", 50, 60, 20, Color.Maroon);
// Draw text box
if (GuiTextBox(new Rectangle(50, 120, 652, 40), inputBuffer, 256, textBoxEditMode)) textBoxEditMode = !textBoxEditMode;
if (GuiTextBox(new Rectangle(50, 120, 652, 40), inputBuffer, 256, textBoxEditMode))
{
textBoxEditMode = !textBoxEditMode;
}
// Random text button
btnRandomPressed = GuiButton(new Rectangle(50 + 652 + 8, 120, 40, 40), "RND");
@ -178,7 +187,11 @@ public partial class ClipboardText : IExample
inputBuffer.Clear();
if (text != null)
{
if (text.Length > 255) text = text.Substring(0, 255);
if (text.Length > 255)
{
text = text.Substring(0, 255);
}
inputBuffer.Append(text);
}
}
@ -204,7 +217,10 @@ public partial class ClipboardText : IExample
int textWidth = MeasureText(text, 20);
DrawText(text, (int)(bounds.X + (bounds.Width - textWidth) / 2), (int)(bounds.Y + (bounds.Height - 20) / 2), 20, Color.DarkGray);
if (hover && IsMouseButtonReleased(MouseButton.Left)) pressed = true;
if (hover && IsMouseButtonReleased(MouseButton.Left))
{
pressed = true;
}
return pressed;
}
@ -229,7 +245,10 @@ public partial class ClipboardText : IExample
key = GetCharPressed();
}
if (IsKeyPressed(KeyboardKey.Backspace) && (text.Length > 0)) text.Remove(text.Length - 1, 1);
if (IsKeyPressed(KeyboardKey.Backspace) && (text.Length > 0))
{
text.Remove(text.Length - 1, 1);
}
}
DrawRectangleRec(bounds, Color.RayWhite);
@ -244,7 +263,10 @@ public partial class ClipboardText : IExample
DrawText("_", (int)bounds.X + 4 + MeasureText(content, 20), (int)(bounds.Y + (bounds.Height - 20) / 2), 20, Color.DarkGray);
}
if (hover && IsMouseButtonPressed(MouseButton.Left)) pressed = true;
if (hover && IsMouseButtonPressed(MouseButton.Left))
{
pressed = true;
}
return pressed;
}
@ -253,7 +275,10 @@ public partial class ClipboardText : IExample
{
DrawRectangleRec(bounds, Color.LightGray);
DrawRectangleLinesEx(bounds, 1, Color.Gray);
if (text != null) DrawText(text, (int)bounds.X + 4, (int)(bounds.Y + (bounds.Height - 20) / 2), 20, Color.Gray);
if (text != null)
{
DrawText(text, (int)bounds.X + 4, (int)(bounds.Y + (bounds.Height - 20) / 2), 20, Color.Gray);
}
}
public static int Main()

View file

@ -17,10 +17,7 @@
// raygui is not bound in raylib-cs, so the widgets below are minimal re-implementations
// using plain raylib drawing/input. The hashing/Base64 logic is a faithful port.
using System;
using System.Numerics;
using System.Text;
using static Raylib_cs.Raylib;
namespace Examples.Core;
@ -101,7 +98,10 @@ public unsafe partial class ComputeHash : IExample
GuiLabel(new Rectangle(40, 26, 720, 32), "INPUT DATA (TEXT):", 20);
if (GuiTextBox(new Rectangle(40, 64, 720, 32), textInput, 95, textBoxEditMode, 10)) textBoxEditMode = !textBoxEditMode;
if (GuiTextBox(new Rectangle(40, 64, 720, 32), textInput, 95, textBoxEditMode, 10))
{
textBoxEditMode = !textBoxEditMode;
}
btnComputeHashes = GuiButton(new Rectangle(40, 64 + 40, 720, 32), "COMPUTE INPUT DATA HASHES", 10);
@ -133,10 +133,17 @@ public unsafe partial class ComputeHash : IExample
//----------------------------------------------------------------------------------
private static uint[] CopyHash(uint* data, int count)
{
if (data == null) return null;
if (data == null)
{
return null;
}
uint[] result = new uint[count];
for (int i = 0; i < count; i++) result[i] = data[i];
for (int i = 0; i < count; i++)
{
result[i] = data[i];
}
return result;
}
@ -145,7 +152,11 @@ public unsafe partial class ComputeHash : IExample
if ((data != null) && (dataSize > 0) && (dataSize < ((128 / 8) - 1)))
{
StringBuilder text = new StringBuilder();
for (int i = 0; i < dataSize; i++) text.Append(data[i].ToString("X8"));
for (int i = 0; i < dataSize; i++)
{
text.Append(data[i].ToString("X8"));
}
return text.ToString();
}
@ -173,7 +184,10 @@ public unsafe partial class ComputeHash : IExample
int textWidth = MeasureText(text, fontSize);
DrawText(text, (int)(bounds.X + (bounds.Width - textWidth) / 2), (int)(bounds.Y + (bounds.Height - fontSize) / 2), fontSize, Color.DarkGray);
if (hover && IsMouseButtonReleased(MouseButton.Left)) pressed = true;
if (hover && IsMouseButtonReleased(MouseButton.Left))
{
pressed = true;
}
return pressed;
}
@ -197,7 +211,10 @@ public unsafe partial class ComputeHash : IExample
key = GetCharPressed();
}
if (IsKeyPressed(KeyboardKey.Backspace) && (text.Length > 0)) text.Remove(text.Length - 1, 1);
if (IsKeyPressed(KeyboardKey.Backspace) && (text.Length > 0))
{
text.Remove(text.Length - 1, 1);
}
}
DrawRectangleRec(bounds, Color.RayWhite);
@ -211,7 +228,10 @@ public unsafe partial class ComputeHash : IExample
DrawText("_", (int)bounds.X + 4 + MeasureText(content, fontSize), (int)(bounds.Y + (bounds.Height - fontSize) / 2), fontSize, Color.DarkGray);
}
if (hover && IsMouseButtonPressed(MouseButton.Left)) pressed = true;
if (hover && IsMouseButtonPressed(MouseButton.Left))
{
pressed = true;
}
return pressed;
}
@ -220,7 +240,10 @@ public unsafe partial class ComputeHash : IExample
{
DrawRectangleRec(bounds, Color.LightGray);
DrawRectangleLinesEx(bounds, 1, Color.Gray);
if (text != null) DrawText(text, (int)bounds.X + 4, (int)(bounds.Y + (bounds.Height - fontSize) / 2), fontSize, Color.Gray);
if (text != null)
{
DrawText(text, (int)bounds.X + 4, (int)(bounds.Y + (bounds.Height - fontSize) / 2), fontSize, Color.Gray);
}
}
public static int Main()

View file

@ -28,8 +28,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
// NOTE: This example is intended to run against a raylib built with SUPPORT_CUSTOM_FRAME_CONTROL,
@ -84,17 +82,33 @@ public partial class CustomFrameControl : IExample
PollInputEvents(); // Poll input events (SUPPORT_CUSTOM_FRAME_CONTROL)
#endif
if (IsKeyPressed(KeyboardKey.Space)) pause = !pause;
if (IsKeyPressed(KeyboardKey.Space))
{
pause = !pause;
}
if (IsKeyPressed(KeyboardKey.Up)) targetFPS += 20;
else if (IsKeyPressed(KeyboardKey.Down)) targetFPS -= 20;
if (IsKeyPressed(KeyboardKey.Up))
{
targetFPS += 20;
}
else if (IsKeyPressed(KeyboardKey.Down))
{
targetFPS -= 20;
}
if (targetFPS < 0) targetFPS = 0;
if (targetFPS < 0)
{
targetFPS = 0;
}
if (!pause)
{
position += 200 * deltaTime; // We move at 200 pixels per second
if (position >= GetScreenWidth()) position = 0;
if (position >= GetScreenWidth())
{
position = 0;
}
timeCounter += deltaTime; // We count time (seconds)
}
@ -111,7 +125,10 @@ public partial class CustomFrameControl : IExample
ClearBackground(Color.RayWhite);
for (int i = 0; i < GetScreenWidth() / 200; i++) DrawRectangle(200 * i, 0, 1, GetScreenHeight(), Color.SkyBlue);
for (int i = 0; i < GetScreenWidth() / 200; i++)
{
DrawRectangle(200 * i, 0, 1, GetScreenHeight(), Color.SkyBlue);
}
DrawCircle((int)position, GetScreenHeight() / 2 - 25, 50, Color.Red);
@ -147,7 +164,10 @@ public partial class CustomFrameControl : IExample
deltaTime = (float)(currentTime - previousTime);
}
}
else deltaTime = (float)updateDrawTime; // Framerate could be variable
else
{
deltaTime = (float)updateDrawTime; // Framerate could be variable
}
previousTime = currentTime;
//----------------------------------------------------------------------------------

View file

@ -15,9 +15,7 @@
*
********************************************************************************************/
using System;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Core;

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
namespace Examples.Core;
using static Raylib_cs.Raylib;

View file

@ -20,10 +20,6 @@
// list view are reimplemented here with plain raylib primitives. The directory navigation
// behaviour (enter directories, go back) is preserved.
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class DirectoryFiles : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Collections.Generic;
using static Raylib_cs.Raylib;
namespace Examples.Core;
[ExcludeFromBrowser]

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
[ExcludeFromBrowser("monitor/DPI APIs are meaningless on the fixed wasm canvas")]

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
[ExcludeFromBrowser("fullscreen/borderless/monitor APIs are meaningless on the fixed wasm canvas")]

View file

@ -19,9 +19,6 @@
// 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
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputActions : IExample
@ -82,10 +79,26 @@ public partial class InputActions : IExample
//----------------------------------------------------------------------------------
gamepadIndex = 0; // Set gamepad being checked
if (IsActionDown(ActionType.ActionUp)) position.Y -= 2;
if (IsActionDown(ActionType.ActionDown)) position.Y += 2;
if (IsActionDown(ActionType.ActionLeft)) position.X -= 2;
if (IsActionDown(ActionType.ActionRight)) position.X += 2;
if (IsActionDown(ActionType.ActionUp))
{
position.Y -= 2;
}
if (IsActionDown(ActionType.ActionDown))
{
position.Y += 2;
}
if (IsActionDown(ActionType.ActionLeft))
{
position.X -= 2;
}
if (IsActionDown(ActionType.ActionRight))
{
position.X += 2;
}
if (IsActionPressed(ActionType.ActionFire))
{
position.X = (screenWidth - size.X) / 2;
@ -94,14 +107,23 @@ public partial class InputActions : IExample
// Register release action for one frame
releaseAction = false;
if (IsActionReleased(ActionType.ActionFire)) releaseAction = true;
if (IsActionReleased(ActionType.ActionFire))
{
releaseAction = true;
}
// Switch control scheme by pressing TAB
if (IsKeyPressed(KeyboardKey.Tab))
{
actionSet = (actionSet == 0) ? 1 : 0;
if (actionSet == 0) SetActionsDefault();
else SetActionsCursor();
if (actionSet == 0)
{
SetActionsDefault();
}
else
{
SetActionsCursor();
}
}
//----------------------------------------------------------------------------------
@ -133,7 +155,10 @@ public partial class InputActions : IExample
{
bool result = false;
if (action < ActionType.MaxAction) result = (IsKeyPressed(actionInputs[(int)action].Key) || IsGamepadButtonPressed(gamepadIndex, actionInputs[(int)action].Button));
if (action < ActionType.MaxAction)
{
result = (IsKeyPressed(actionInputs[(int)action].Key) || IsGamepadButtonPressed(gamepadIndex, actionInputs[(int)action].Button));
}
return result;
}
@ -144,7 +169,10 @@ public partial class InputActions : IExample
{
bool result = false;
if (action < ActionType.MaxAction) result = (IsKeyReleased(actionInputs[(int)action].Key) || IsGamepadButtonReleased(gamepadIndex, actionInputs[(int)action].Button));
if (action < ActionType.MaxAction)
{
result = (IsKeyReleased(actionInputs[(int)action].Key) || IsGamepadButtonReleased(gamepadIndex, actionInputs[(int)action].Button));
}
return result;
}
@ -155,7 +183,10 @@ public partial class InputActions : IExample
{
bool result = false;
if (action < ActionType.MaxAction) result = (IsKeyDown(actionInputs[(int)action].Key) || IsGamepadButtonDown(gamepadIndex, actionInputs[(int)action].Button));
if (action < ActionType.MaxAction)
{
result = (IsKeyDown(actionInputs[(int)action].Key) || IsGamepadButtonDown(gamepadIndex, actionInputs[(int)action].Button));
}
return result;
}

View file

@ -19,9 +19,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputGamepad : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputGestures : IExample

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputGesturesTestBed : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputKeys : IExample

View file

@ -14,9 +14,6 @@
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputMouse : IExample

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputMouseWheel : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class InputMultitouch : IExample

View file

@ -16,10 +16,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public enum PadButton

View file

@ -16,9 +16,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class KeyboardTestbed : IExample
@ -53,7 +50,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 01
line01KeyWidths = new int[15];
for (int i = 0; i < 15; i++) line01KeyWidths[i] = 45;
for (int i = 0; i < 15; i++)
{
line01KeyWidths[i] = 45;
}
line01KeyWidths[13] = 62; // PRINTSCREEN
line01Keys = new int[]
{
@ -64,7 +65,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 02
line02KeyWidths = new int[15];
for (int i = 0; i < 15; i++) line02KeyWidths[i] = 45;
for (int i = 0; i < 15; i++)
{
line02KeyWidths[i] = 45;
}
line02KeyWidths[0] = 25; // GRAVE
line02KeyWidths[13] = 82; // BACKSPACE
line02Keys = new int[]
@ -76,7 +81,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 03
line03KeyWidths = new int[15];
for (int i = 0; i < 15; i++) line03KeyWidths[i] = 45;
for (int i = 0; i < 15; i++)
{
line03KeyWidths[i] = 45;
}
line03KeyWidths[0] = 50; // TAB
line03KeyWidths[13] = 57; // BACKSLASH
line03Keys = new int[]
@ -88,7 +97,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 04
line04KeyWidths = new int[14];
for (int i = 0; i < 14; i++) line04KeyWidths[i] = 45;
for (int i = 0; i < 14; i++)
{
line04KeyWidths[i] = 45;
}
line04KeyWidths[0] = 68; // CAPS
line04KeyWidths[12] = 88; // ENTER
line04Keys = new int[]
@ -100,7 +113,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 05
line05KeyWidths = new int[14];
for (int i = 0; i < 14; i++) line05KeyWidths[i] = 45;
for (int i = 0; i < 14; i++)
{
line05KeyWidths[i] = 45;
}
line05KeyWidths[0] = 80; // LSHIFT
line05KeyWidths[11] = 76; // RSHIFT
line05Keys = new int[]
@ -112,7 +129,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 06
line06KeyWidths = new int[11];
for (int i = 0; i < 11; i++) line06KeyWidths[i] = 45;
for (int i = 0; i < 11; i++)
{
line06KeyWidths[i] = 45;
}
line06KeyWidths[0] = 80; // LCTRL
line06KeyWidths[3] = 208; // SPACE
line06KeyWidths[7] = 60; // RCTRL
@ -131,10 +152,16 @@ public partial class KeyboardTestbed : IExample
// Update
//----------------------------------------------------------------------------------
int key = GetKeyPressed(); // Get pressed keycode
if (key > 0) TraceLog(TraceLogLevel.Info, $"KEYBOARD TESTBED: KEY PRESSED: {key}");
if (key > 0)
{
TraceLog(TraceLogLevel.Info, $"KEYBOARD TESTBED: KEY PRESSED: {key}");
}
int ch = GetCharPressed(); // Get pressed char for text input, using OS mapping
if (ch > 0) TraceLog(TraceLogLevel.Info, $"KEYBOARD TESTBED: CHAR PRESSED: {(char)ch} ({ch})");
if (ch > 0)
{
TraceLog(TraceLogLevel.Info, $"KEYBOARD TESTBED: CHAR PRESSED: {(char)ch} ({ch})");
}
//----------------------------------------------------------------------------------
// Draw
@ -322,7 +349,10 @@ public partial class KeyboardTestbed : IExample
// Draw keyboard key
private static void GuiKeyboardKey(Rectangle bounds, int key)
{
if (key == (int)KeyboardKey.Null) DrawRectangleLinesEx(bounds, 2.0f, Color.LightGray);
if (key == (int)KeyboardKey.Null)
{
DrawRectangleLinesEx(bounds, 2.0f, Color.LightGray);
}
else
{
if (IsKeyDown((KeyboardKey)key))

View file

@ -13,8 +13,6 @@
********************************************************************************************/
using System.Diagnostics;
using System.Threading;
using static Raylib_cs.Raylib;
namespace Examples.Core;

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
[ExcludeFromBrowser("GetMonitorCount() is not implemented on the wasm target")]

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class Picking3d : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Core;

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class RandomValues : IExample

View file

@ -13,10 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class RenderTextureDemo : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class ScissorTest : IExample

View file

@ -13,11 +13,6 @@
*
********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
// NOTE: The upstream C example records frames into an animated GIF using the bundled msf_gif.h
@ -251,7 +246,10 @@ public partial class ScreenRecording : IExample
public unsafe void AddFrame(byte* data, int w, int h, int stride, int delayCs)
{
if (output == null) return;
if (output == null)
{
return;
}
// Graphic Control Extension
output.Add(0x21);
@ -317,7 +315,10 @@ public partial class ScreenRecording : IExample
nkeys++;
if (nkeys == (1 << keySize))
{
if (keySize < 12) keySize++;
if (keySize < 12)
{
keySize++;
}
}
if (nkeys == 0x1000)
{
@ -340,13 +341,21 @@ public partial class ScreenRecording : IExample
bitBuffer = 0;
bitCount = 0;
}
if (subBlock.Count > 0) FlushSubBlock();
if (subBlock.Count > 0)
{
FlushSubBlock();
}
output.Add(0x00); // Image data block terminator
}
public byte[] End()
{
if (output == null) return Array.Empty<byte>();
if (output == null)
{
return Array.Empty<byte>();
}
output.Add(0x3B); // Trailer
byte[] result = output.ToArray();
output = null;
@ -362,7 +371,10 @@ public partial class ScreenRecording : IExample
subBlock.Add((byte)(bitBuffer & 0xFF));
bitBuffer >>= 8;
bitCount -= 8;
if (subBlock.Count == 255) FlushSubBlock();
if (subBlock.Count == 255)
{
FlushSubBlock();
}
}
}

View file

@ -16,10 +16,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class SmoothPixelPerfect : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class SplitScreen : IExample

View file

@ -18,9 +18,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class SplitScreen2D : IExample
@ -74,15 +71,41 @@ public partial class SplitScreen2D : IExample
{
// Update
//----------------------------------------------------------------------------------
if (IsKeyDown(KeyboardKey.S)) player1.Y += 3.0f;
else if (IsKeyDown(KeyboardKey.W)) player1.Y -= 3.0f;
if (IsKeyDown(KeyboardKey.D)) player1.X += 3.0f;
else if (IsKeyDown(KeyboardKey.A)) player1.X -= 3.0f;
if (IsKeyDown(KeyboardKey.S))
{
player1.Y += 3.0f;
}
else if (IsKeyDown(KeyboardKey.W))
{
player1.Y -= 3.0f;
}
if (IsKeyDown(KeyboardKey.Up)) player2.Y -= 3.0f;
else if (IsKeyDown(KeyboardKey.Down)) player2.Y += 3.0f;
if (IsKeyDown(KeyboardKey.Right)) player2.X += 3.0f;
else if (IsKeyDown(KeyboardKey.Left)) player2.X -= 3.0f;
if (IsKeyDown(KeyboardKey.D))
{
player1.X += 3.0f;
}
else if (IsKeyDown(KeyboardKey.A))
{
player1.X -= 3.0f;
}
if (IsKeyDown(KeyboardKey.Up))
{
player2.Y -= 3.0f;
}
else if (IsKeyDown(KeyboardKey.Down))
{
player2.Y += 3.0f;
}
if (IsKeyDown(KeyboardKey.Right))
{
player2.X += 3.0f;
}
else if (IsKeyDown(KeyboardKey.Left))
{
player2.X -= 3.0f;
}
camera1.Target = new Vector2(player1.X, player1.Y);
camera2.Target = new Vector2(player2.X, player2.Y);

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class StorageValues : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Core;
@ -125,11 +123,16 @@ public partial class TextFileLoading : IExample
float scroll = GetMouseWheelMove();
cam.Target.Y -= scroll * fontSize * 1.5f; // Choosing an arbitrary speed for scroll
if (cam.Target.Y < 0) cam.Target.Y = 0; // Snapping to 0 if we go too far back
if (cam.Target.Y < 0)
{
cam.Target.Y = 0; // Snapping to 0 if we go too far back
}
// Ensuring that the camera does not scroll past all text
if (cam.Target.Y > textHeight - screenHeight + textTop)
{
cam.Target.Y = (float)textHeight - screenHeight + textTop;
}
// Computing the position of the scrollBar depending on the percentage of text covered
scrollBar.Y = Lerp((float)textTop, (float)screenHeight - scrollBar.Height, (float)(cam.Target.Y - textTop) / (textHeight - screenHeight));

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class UndoRedo : IExample
@ -87,7 +84,10 @@ public partial class UndoRedo : IExample
// Init undo buffer to store MAX_UNDO_STATES states
states = new PlayerState[MAX_UNDO_STATES];
// Init all undo states to current state
for (int i = 0; i < MAX_UNDO_STATES; i++) states[i] = player;
for (int i = 0; i < MAX_UNDO_STATES; i++)
{
states[i] = player;
}
// Grid variables
gridPosition = new Vector2(40, 60);
@ -98,16 +98,41 @@ public partial class UndoRedo : IExample
// Update
//----------------------------------------------------------------------------------
// Player movement logic
if (IsKeyPressed(KeyboardKey.Right)) player.Cell.X++;
else if (IsKeyPressed(KeyboardKey.Left)) player.Cell.X--;
else if (IsKeyPressed(KeyboardKey.Up)) player.Cell.Y--;
else if (IsKeyPressed(KeyboardKey.Down)) player.Cell.Y++;
if (IsKeyPressed(KeyboardKey.Right))
{
player.Cell.X++;
}
else if (IsKeyPressed(KeyboardKey.Left))
{
player.Cell.X--;
}
else if (IsKeyPressed(KeyboardKey.Up))
{
player.Cell.Y--;
}
else if (IsKeyPressed(KeyboardKey.Down))
{
player.Cell.Y++;
}
// Make sure player does not go out of bounds
if (player.Cell.X < 0) player.Cell.X = 0;
else if (player.Cell.X >= MAX_GRID_CELLS_X) player.Cell.X = MAX_GRID_CELLS_X - 1;
if (player.Cell.Y < 0) player.Cell.Y = 0;
else if (player.Cell.Y >= MAX_GRID_CELLS_Y) player.Cell.Y = MAX_GRID_CELLS_Y - 1;
if (player.Cell.X < 0)
{
player.Cell.X = 0;
}
else if (player.Cell.X >= MAX_GRID_CELLS_X)
{
player.Cell.X = MAX_GRID_CELLS_X - 1;
}
if (player.Cell.Y < 0)
{
player.Cell.Y = 0;
}
else if (player.Cell.Y >= MAX_GRID_CELLS_Y)
{
player.Cell.Y = MAX_GRID_CELLS_Y - 1;
}
// Player color change logic
if (IsKeyPressed(KeyboardKey.Space))
@ -127,9 +152,20 @@ public partial class UndoRedo : IExample
{
// Move cursor to next available position of the undo ring buffer to record state
currentUndoIndex++;
if (currentUndoIndex >= MAX_UNDO_STATES) currentUndoIndex = 0;
if (currentUndoIndex == firstUndoIndex) firstUndoIndex++;
if (firstUndoIndex >= MAX_UNDO_STATES) firstUndoIndex = 0;
if (currentUndoIndex >= MAX_UNDO_STATES)
{
currentUndoIndex = 0;
}
if (currentUndoIndex == firstUndoIndex)
{
firstUndoIndex++;
}
if (firstUndoIndex >= MAX_UNDO_STATES)
{
firstUndoIndex = 0;
}
states[currentUndoIndex] = player;
lastUndoIndex = currentUndoIndex;
@ -144,7 +180,10 @@ public partial class UndoRedo : IExample
if (currentUndoIndex != firstUndoIndex)
{
currentUndoIndex--;
if (currentUndoIndex < 0) currentUndoIndex = MAX_UNDO_STATES - 1;
if (currentUndoIndex < 0)
{
currentUndoIndex = MAX_UNDO_STATES - 1;
}
if (!SameState(states[currentUndoIndex], player))
{
@ -159,7 +198,10 @@ public partial class UndoRedo : IExample
if (currentUndoIndex != lastUndoIndex)
{
int nextUndoIndex = currentUndoIndex + 1;
if (nextUndoIndex >= MAX_UNDO_STATES) nextUndoIndex = 0;
if (nextUndoIndex >= MAX_UNDO_STATES)
{
nextUndoIndex = 0;
}
if (nextUndoIndex != firstUndoIndex)
{
@ -188,35 +230,49 @@ public partial class UndoRedo : IExample
if (lastUndoIndex > firstUndoIndex)
{
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
{
DrawRectangleRec(new Rectangle(gridPosition.X + states[i].Cell.X * GRID_CELL_SIZE, gridPosition.Y + states[i].Cell.Y * GRID_CELL_SIZE,
GRID_CELL_SIZE, GRID_CELL_SIZE), Color.LightGray);
}
}
else if (firstUndoIndex > lastUndoIndex)
{
if ((currentUndoIndex < MAX_UNDO_STATES) && (currentUndoIndex > lastUndoIndex))
{
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
{
DrawRectangleRec(new Rectangle(gridPosition.X + states[i].Cell.X * GRID_CELL_SIZE, gridPosition.Y + states[i].Cell.Y * GRID_CELL_SIZE,
GRID_CELL_SIZE, GRID_CELL_SIZE), Color.LightGray);
}
}
else
{
for (int i = firstUndoIndex; i < MAX_UNDO_STATES; i++)
{
DrawRectangle((int)gridPosition.X + states[i].Cell.X * GRID_CELL_SIZE, (int)gridPosition.Y + states[i].Cell.Y * GRID_CELL_SIZE,
GRID_CELL_SIZE, GRID_CELL_SIZE, Color.LightGray);
}
for (int i = 0; i < currentUndoIndex; i++)
{
DrawRectangle((int)gridPosition.X + states[i].Cell.X * GRID_CELL_SIZE, (int)gridPosition.Y + states[i].Cell.Y * GRID_CELL_SIZE,
GRID_CELL_SIZE, GRID_CELL_SIZE, Color.LightGray);
}
}
}
// Draw game grid
for (int y = 0; y <= MAX_GRID_CELLS_Y; y++)
{
DrawLine((int)gridPosition.X, (int)gridPosition.Y + y * GRID_CELL_SIZE,
(int)gridPosition.X + MAX_GRID_CELLS_X * GRID_CELL_SIZE, (int)gridPosition.Y + y * GRID_CELL_SIZE, Color.Gray);
}
for (int x = 0; x <= MAX_GRID_CELLS_X; x++)
{
DrawLine((int)gridPosition.X + x * GRID_CELL_SIZE, (int)gridPosition.Y,
(int)gridPosition.X + x * GRID_CELL_SIZE, (int)gridPosition.Y + MAX_GRID_CELLS_Y * GRID_CELL_SIZE, Color.Gray);
}
// Draw player
DrawRectangle((int)gridPosition.X + player.Cell.X * GRID_CELL_SIZE, (int)gridPosition.Y + player.Cell.Y * GRID_CELL_SIZE,

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class ViewportScaling : IExample
@ -116,7 +113,10 @@ public partial class ViewportScaling : IExample
{
// Update
//----------------------------------------------------------------------------------
if (IsWindowResized()) ResizeRenderSize(viewportType, ref curScreenWidth, ref curScreenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect, ref target);
if (IsWindowResized())
{
ResizeRenderSize(viewportType, ref curScreenWidth, ref curScreenHeight, gameWidth, gameHeight, ref sourceRect, ref destRect, ref target);
}
Vector2 mousePosition = GetMousePosition();
bool mousePressed = IsMouseButtonPressed(MouseButton.Left);
@ -179,8 +179,14 @@ public partial class ViewportScaling : IExample
DrawText($"Type: {ViewportTypeNames[(int)viewportType]}", 15, 45, 10, Color.Black);
Vector2 scaleRatio = new Vector2(destRect.Width / sourceRect.Width, -destRect.Height / sourceRect.Height);
if (scaleRatio.X < 0.001f || scaleRatio.Y < 0.001f) DrawText("Scale ratio: INVALID", 15, 60, 10, Color.Black);
else DrawText($"Scale ratio: {scaleRatio.X:F2} x {scaleRatio.Y:F2}", 15, 60, 10, Color.Black);
if (scaleRatio.X < 0.001f || scaleRatio.Y < 0.001f)
{
DrawText("Scale ratio: INVALID", 15, 60, 10, Color.Black);
}
else
{
DrawText($"Scale ratio: {scaleRatio.X:F2} x {scaleRatio.Y:F2}", 15, 60, 10, Color.Black);
}
DrawText($"Source size: {sourceRect.Width:F2} x {-sourceRect.Height:F2}", 15, 75, 10, Color.Black);
DrawText($"Destination size: {destRect.Width:F2} x {destRect.Height:F2}", 15, 90, 10, Color.Black);

View file

@ -13,10 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class VrSimulator : IExample

View file

@ -13,8 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.ConfigFlags;
namespace Examples.Core;

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class WindowLetterbox : IExample

View file

@ -13,10 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class WindowShouldClose : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core;
public partial class WorldScreen : IExample

View file

@ -24,9 +24,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -22,9 +22,6 @@
// raygui is not part of raylib-cs, so the required controls are reimplemented here with
// basic raylib drawing primitives, preserving the original behaviour.
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class AnimationBlending : IExample

View file

@ -18,9 +18,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class AnimationGpuSkinning : IExample

View file

@ -17,9 +17,6 @@
// raygui is not part of raylib-cs, so the required controls are reimplemented here with
// basic raylib drawing primitives, preserving the original behaviour.
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class AnimationTiming : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class BasicVoxel : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class BillboardDemo : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class BoxCollisions : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class CubicmapDemo : IExample

View file

@ -16,10 +16,6 @@
*
********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -16,9 +16,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -1,6 +1,3 @@
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class DynamicMesh : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public unsafe partial class FirstPersonMaze : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class GeometricShapes : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class HeightmapDemo : IExample

View file

@ -20,9 +20,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class LoadingGltf : IExample

View file

@ -19,10 +19,6 @@
*
********************************************************************************************/
using System.Numerics;
using System.Runtime.InteropServices;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class LoadingIqm : IExample

View file

@ -19,9 +19,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class LoadingM3d : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
using Examples.Shared;

View file

@ -1,6 +1,3 @@
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class MeshDemo : IExample

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class MeshGeneration : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -13,9 +13,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class ModelCubeTexture : IExample

View file

@ -26,9 +26,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class ModelLoading : IExample

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class OrthographicProjection : IExample

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
[ExcludeFromBrowser("rlEnablePointMode needs glPolygonMode, which OpenGL ES/WebGL lacks (renders as triangles)")]

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class RotatingCube : IExample

View file

@ -13,10 +13,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
[ExcludeFromBrowser("cubemap generation is too memory-heavy on web (upstream note)")]

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class SolarSystem : IExample

View file

@ -17,9 +17,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;
@ -120,7 +117,10 @@ public partial class TesseractView : IExample
int diff = (v1.X == v2.X ? 1 : 0) + (v1.Y == v2.Y ? 1 : 0) + (v1.Z == v2.Z ? 1 : 0) + (v1.W == v2.W ? 1 : 0);
// Draw only differing by 1 coordinate and the lower index only (duplicate lines)
if (diff == 3 && i < j) DrawLine3D(transformed[i], transformed[j], Color.Maroon);
if (diff == 3 && i < j)
{
DrawLine3D(transformed[i], transformed[j], Color.Maroon);
}
}
}
EndMode3D();

View file

@ -15,10 +15,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Models;
public partial class WavingCubes : IExample

View file

@ -15,8 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
namespace Examples.Models;

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Shaders;
public partial class AsciiRendering : IExample

View file

@ -20,8 +20,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
using Examples.Shared;
namespace Examples.Shaders;

View file

@ -19,9 +19,7 @@
*
********************************************************************************************/
using System.Numerics;
using Examples.Shared;
using static Raylib_cs.Raylib;
namespace Examples.Shaders;

View file

@ -18,9 +18,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath;
using static Raylib_cs.Rlgl;
using Examples.Shared;

View file

@ -18,8 +18,6 @@
*
********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Shaders;
public partial class ColorCorrection : IExample
@ -85,10 +83,22 @@ public partial class ColorCorrection : IExample
// Update
//----------------------------------------------------------------------------------
// Select texture to draw
if (IsKeyPressed(KeyboardKey.One)) imageIndex = 0;
else if (IsKeyPressed(KeyboardKey.Two)) imageIndex = 1;
else if (IsKeyPressed(KeyboardKey.Three)) imageIndex = 2;
else if (IsKeyPressed(KeyboardKey.Four)) imageIndex = 3;
if (IsKeyPressed(KeyboardKey.One))
{
imageIndex = 0;
}
else if (IsKeyPressed(KeyboardKey.Two))
{
imageIndex = 1;
}
else if (IsKeyPressed(KeyboardKey.Three))
{
imageIndex = 2;
}
else if (IsKeyPressed(KeyboardKey.Four))
{
imageIndex = 3;
}
// Reset values to 0
if (IsKeyPressed(KeyboardKey.R) || resetButtonClicked != 0)

View file

@ -20,9 +20,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Shaders;
public class CustomUniform : IExample

View file

@ -17,9 +17,6 @@
*
********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using Examples.Shared;
namespace Examples.Shaders;
@ -218,13 +215,31 @@ public partial class DeferredRendering : IExample
if (IsKeyPressed(KeyboardKey.B)) { lights[3].Enabled = !lights[3].Enabled; }
// Check key inputs to switch between G-buffer textures
if (IsKeyPressed(KeyboardKey.One)) mode = DeferredMode.Position;
if (IsKeyPressed(KeyboardKey.Two)) mode = DeferredMode.Normal;
if (IsKeyPressed(KeyboardKey.Three)) mode = DeferredMode.Albedo;
if (IsKeyPressed(KeyboardKey.Four)) mode = DeferredMode.Shading;
if (IsKeyPressed(KeyboardKey.One))
{
mode = DeferredMode.Position;
}
if (IsKeyPressed(KeyboardKey.Two))
{
mode = DeferredMode.Normal;
}
if (IsKeyPressed(KeyboardKey.Three))
{
mode = DeferredMode.Albedo;
}
if (IsKeyPressed(KeyboardKey.Four))
{
mode = DeferredMode.Shading;
}
// Update light values (actually, only enable/disable them)
for (var i = 0; i < MaxLights; i++) Rlights.UpdateLightValues(deferredShader, lights[i]);
for (var i = 0; i < MaxLights; i++)
{
Rlights.UpdateLightValues(deferredShader, lights[i]);
}
//----------------------------------------------------------------------------------
// Draw
@ -295,9 +310,15 @@ public partial class DeferredRendering : IExample
Rlgl.EnableShader(Rlgl.GetShaderIdDefault());
for (var i = 0; i < MaxLights; i++)
{
if (lights[i].Enabled) DrawSphereEx(lights[i].Position, 0.2f, 8, 8, lights[i].Color);
else DrawSphereWires(lights[i].Position, 0.2f, 8, 8, ColorAlpha(lights[i].Color, 0.3f));
}
if (lights[i].Enabled)
{
DrawSphereEx(lights[i].Position, 0.2f, 8, 8, lights[i].Color);
}
else
{
DrawSphereWires(lights[i].Position, 0.2f, 8, 8, ColorAlpha(lights[i].Color, 0.3f));
}
}
Rlgl.DisableShader();
EndMode3D();

View file

@ -15,9 +15,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Shaders;
public class DepthRendering : IExample

View file

@ -27,9 +27,6 @@
*
********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Shaders;
public class Eratosthenes : IExample

Some files were not shown because too many files have changed in this diff Show more