diff --git a/Examples/Audio/AmpEnvelope.cs b/Examples/Audio/AmpEnvelope.cs index 396b3e2..2c1df4b 100644 --- a/Examples/Audio/AmpEnvelope.cs +++ b/Examples/Audio/AmpEnvelope.cs @@ -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 diff --git a/Examples/Audio/MixedProcessor.cs b/Examples/Audio/MixedProcessor.cs index fa85528..dde7ac4 100644 --- a/Examples/Audio/MixedProcessor.cs +++ b/Examples/Audio/MixedProcessor.cs @@ -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 //---------------------------------------------------------------------------------- diff --git a/Examples/Audio/ModulePlaying.cs b/Examples/Audio/ModulePlaying.cs index 39d7829..d669373 100644 --- a/Examples/Audio/ModulePlaying.cs +++ b/Examples/Audio/ModulePlaying.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Audio; public partial class ModulePlaying : IExample diff --git a/Examples/Audio/MusicStreamDemo.cs b/Examples/Audio/MusicStreamDemo.cs index c25d0b8..883c8db 100644 --- a/Examples/Audio/MusicStreamDemo.cs +++ b/Examples/Audio/MusicStreamDemo.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Audio; public partial class MusicStreamDemo : IExample diff --git a/Examples/Audio/RawStream.cs b/Examples/Audio/RawStream.cs index 08f44b0..c179caf 100644 --- a/Examples/Audio/RawStream.cs +++ b/Examples/Audio/RawStream.cs @@ -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); } diff --git a/Examples/Audio/SoundLoading.cs b/Examples/Audio/SoundLoading.cs index 025852c..3cefa75 100644 --- a/Examples/Audio/SoundLoading.cs +++ b/Examples/Audio/SoundLoading.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Audio; public partial class SoundLoading : IExample diff --git a/Examples/Audio/SoundMulti.cs b/Examples/Audio/SoundMulti.cs index 40a88bd..682b5bb 100644 --- a/Examples/Audio/SoundMulti.cs +++ b/Examples/Audio/SoundMulti.cs @@ -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 diff --git a/Examples/Audio/SoundPositioning.cs b/Examples/Audio/SoundPositioning.cs index b5a9a50..74589ef 100644 --- a/Examples/Audio/SoundPositioning.cs +++ b/Examples/Audio/SoundPositioning.cs @@ -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); diff --git a/Examples/Audio/StreamCallback.cs b/Examples/Audio/StreamCallback.cs index 488e19e..f146f9f 100644 --- a/Examples/Audio/StreamCallback.cs +++ b/Examples/Audio/StreamCallback.cs @@ -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() diff --git a/Examples/Audio/StreamEffects.cs b/Examples/Audio/StreamEffects.cs index 9a9c960..cb0ff55 100644 --- a/Examples/Audio/StreamEffects.cs +++ b/Examples/Audio/StreamEffects.cs @@ -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; + } } } } diff --git a/Examples/Core/AutomationEvents.cs b/Examples/Core/AutomationEvents.cs index 6ba6a5c..43b8da3 100644 --- a/Examples/Core/AutomationEvents.cs +++ b/Examples/Core/AutomationEvents.cs @@ -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(); diff --git a/Examples/Core/BasicScreenManager.cs b/Examples/Core/BasicScreenManager.cs index 308d5a0..78dd4d1 100644 --- a/Examples/Core/BasicScreenManager.cs +++ b/Examples/Core/BasicScreenManager.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Core; internal enum GameScreen diff --git a/Examples/Core/BasicWindow.cs b/Examples/Core/BasicWindow.cs index f24c930..ebe4a9f 100644 --- a/Examples/Core/BasicWindow.cs +++ b/Examples/Core/BasicWindow.cs @@ -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 diff --git a/Examples/Core/Camera2dDemo.cs b/Examples/Core/Camera2dDemo.cs index bd9aebf..b4eeca7 100644 --- a/Examples/Core/Camera2dDemo.cs +++ b/Examples/Core/Camera2dDemo.cs @@ -13,10 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class Camera2dDemo : IExample diff --git a/Examples/Core/Camera2dMouseZoom.cs b/Examples/Core/Camera2dMouseZoom.cs index 05d4f39..26554e1 100644 --- a/Examples/Core/Camera2dMouseZoom.cs +++ b/Examples/Core/Camera2dMouseZoom.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Core; diff --git a/Examples/Core/Camera2dPlatformer.cs b/Examples/Core/Camera2dPlatformer.cs index 9f54911..b0429b1 100644 --- a/Examples/Core/Camera2dPlatformer.cs +++ b/Examples/Core/Camera2dPlatformer.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Core; diff --git a/Examples/Core/Camera3dFirstPerson.cs b/Examples/Core/Camera3dFirstPerson.cs index 7f7b951..f82e72f 100644 --- a/Examples/Core/Camera3dFirstPerson.cs +++ b/Examples/Core/Camera3dFirstPerson.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class Camera3dFirstPerson : IExample diff --git a/Examples/Core/Camera3dFps.cs b/Examples/Core/Camera3dFps.cs index bb234d4..cd24279 100644 --- a/Examples/Core/Camera3dFps.cs +++ b/Examples/Core/Camera3dFps.cs @@ -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); diff --git a/Examples/Core/Camera3dFree.cs b/Examples/Core/Camera3dFree.cs index 95cd179..c15012c 100644 --- a/Examples/Core/Camera3dFree.cs +++ b/Examples/Core/Camera3dFree.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class Camera3dFree : IExample diff --git a/Examples/Core/Camera3dMode.cs b/Examples/Core/Camera3dMode.cs index 14c58fa..a5cbccf 100644 --- a/Examples/Core/Camera3dMode.cs +++ b/Examples/Core/Camera3dMode.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class Camera3dMode : IExample diff --git a/Examples/Core/ClipboardText.cs b/Examples/Core/ClipboardText.cs index 0bcbd74..085f5cd 100644 --- a/Examples/Core/ClipboardText.cs +++ b/Examples/Core/ClipboardText.cs @@ -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() diff --git a/Examples/Core/ComputeHash.cs b/Examples/Core/ComputeHash.cs index 69a2d9f..e1c2ef1 100644 --- a/Examples/Core/ComputeHash.cs +++ b/Examples/Core/ComputeHash.cs @@ -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() diff --git a/Examples/Core/CustomFrameControl.cs b/Examples/Core/CustomFrameControl.cs index 2526e8a..07a8a37 100644 --- a/Examples/Core/CustomFrameControl.cs +++ b/Examples/Core/CustomFrameControl.cs @@ -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; //---------------------------------------------------------------------------------- diff --git a/Examples/Core/Customlogging.cs b/Examples/Core/Customlogging.cs index e171cc4..5b8ccb0 100644 --- a/Examples/Core/Customlogging.cs +++ b/Examples/Core/Customlogging.cs @@ -15,9 +15,7 @@ * ********************************************************************************************/ -using System; using System.Runtime.InteropServices; -using static Raylib_cs.Raylib; namespace Examples.Core; diff --git a/Examples/Core/DeltaTime.cs b/Examples/Core/DeltaTime.cs index f83ee51..c741aaf 100644 --- a/Examples/Core/DeltaTime.cs +++ b/Examples/Core/DeltaTime.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; - namespace Examples.Core; using static Raylib_cs.Raylib; diff --git a/Examples/Core/DirectoryFiles.cs b/Examples/Core/DirectoryFiles.cs index 2f7cff3..f494236 100644 --- a/Examples/Core/DirectoryFiles.cs +++ b/Examples/Core/DirectoryFiles.cs @@ -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 diff --git a/Examples/Core/DropFiles.cs b/Examples/Core/DropFiles.cs index c4dcca6..9039de6 100644 --- a/Examples/Core/DropFiles.cs +++ b/Examples/Core/DropFiles.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Collections.Generic; -using static Raylib_cs.Raylib; - namespace Examples.Core; [ExcludeFromBrowser] diff --git a/Examples/Core/HighDpiDemo.cs b/Examples/Core/HighDpiDemo.cs index 2b1ee9b..d79f75c 100644 --- a/Examples/Core/HighDpiDemo.cs +++ b/Examples/Core/HighDpiDemo.cs @@ -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")] diff --git a/Examples/Core/HighDpiTestbed.cs b/Examples/Core/HighDpiTestbed.cs index 43cb649..59a1e5e 100644 --- a/Examples/Core/HighDpiTestbed.cs +++ b/Examples/Core/HighDpiTestbed.cs @@ -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")] diff --git a/Examples/Core/InputActions.cs b/Examples/Core/InputActions.cs index 6b30287..9c11e36 100644 --- a/Examples/Core/InputActions.cs +++ b/Examples/Core/InputActions.cs @@ -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; } diff --git a/Examples/Core/InputGamepad.cs b/Examples/Core/InputGamepad.cs index fc1b915..f5ca41f 100644 --- a/Examples/Core/InputGamepad.cs +++ b/Examples/Core/InputGamepad.cs @@ -19,9 +19,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputGamepad : IExample diff --git a/Examples/Core/InputGestures.cs b/Examples/Core/InputGestures.cs index 50e7edf..1e5afb1 100644 --- a/Examples/Core/InputGestures.cs +++ b/Examples/Core/InputGestures.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputGestures : IExample diff --git a/Examples/Core/InputGesturesTestBed.cs b/Examples/Core/InputGesturesTestBed.cs index ee3d883..add500e 100644 --- a/Examples/Core/InputGesturesTestBed.cs +++ b/Examples/Core/InputGesturesTestBed.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputGesturesTestBed : IExample diff --git a/Examples/Core/InputKeys.cs b/Examples/Core/InputKeys.cs index e15369b..f9b92cc 100644 --- a/Examples/Core/InputKeys.cs +++ b/Examples/Core/InputKeys.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputKeys : IExample diff --git a/Examples/Core/InputMouse.cs b/Examples/Core/InputMouse.cs index a7b105a..7b995c0 100644 --- a/Examples/Core/InputMouse.cs +++ b/Examples/Core/InputMouse.cs @@ -14,9 +14,6 @@ ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputMouse : IExample diff --git a/Examples/Core/InputMouseWheel.cs b/Examples/Core/InputMouseWheel.cs index 92d21fe..d467259 100644 --- a/Examples/Core/InputMouseWheel.cs +++ b/Examples/Core/InputMouseWheel.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputMouseWheel : IExample diff --git a/Examples/Core/InputMultitouch.cs b/Examples/Core/InputMultitouch.cs index ac93aea..f57310c 100644 --- a/Examples/Core/InputMultitouch.cs +++ b/Examples/Core/InputMultitouch.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class InputMultitouch : IExample diff --git a/Examples/Core/InputVirtualControls.cs b/Examples/Core/InputVirtualControls.cs index 1477eb5..2d5ae01 100644 --- a/Examples/Core/InputVirtualControls.cs +++ b/Examples/Core/InputVirtualControls.cs @@ -16,10 +16,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public enum PadButton diff --git a/Examples/Core/KeyboardTestbed.cs b/Examples/Core/KeyboardTestbed.cs index ad413da..d01bf64 100644 --- a/Examples/Core/KeyboardTestbed.cs +++ b/Examples/Core/KeyboardTestbed.cs @@ -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)) diff --git a/Examples/Core/LoadingThread.cs b/Examples/Core/LoadingThread.cs index 0371097..662e089 100644 --- a/Examples/Core/LoadingThread.cs +++ b/Examples/Core/LoadingThread.cs @@ -13,8 +13,6 @@ ********************************************************************************************/ using System.Diagnostics; -using System.Threading; -using static Raylib_cs.Raylib; namespace Examples.Core; diff --git a/Examples/Core/MonitorDetector.cs b/Examples/Core/MonitorDetector.cs index 9ecc0ec..b917416 100644 --- a/Examples/Core/MonitorDetector.cs +++ b/Examples/Core/MonitorDetector.cs @@ -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")] diff --git a/Examples/Core/Picking3D.cs b/Examples/Core/Picking3D.cs index d76948c..aa1574e 100644 --- a/Examples/Core/Picking3D.cs +++ b/Examples/Core/Picking3D.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class Picking3d : IExample diff --git a/Examples/Core/RandomSequence.cs b/Examples/Core/RandomSequence.cs index ccd1dd6..0a6520d 100644 --- a/Examples/Core/RandomSequence.cs +++ b/Examples/Core/RandomSequence.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Core; diff --git a/Examples/Core/RandomValues.cs b/Examples/Core/RandomValues.cs index 86152d2..236c540 100644 --- a/Examples/Core/RandomValues.cs +++ b/Examples/Core/RandomValues.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class RandomValues : IExample diff --git a/Examples/Core/RenderTexture.cs b/Examples/Core/RenderTexture.cs index 358a9da..fd9b864 100644 --- a/Examples/Core/RenderTexture.cs +++ b/Examples/Core/RenderTexture.cs @@ -13,10 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class RenderTextureDemo : IExample diff --git a/Examples/Core/ScissorTest.cs b/Examples/Core/ScissorTest.cs index 4902e69..fbd86a4 100644 --- a/Examples/Core/ScissorTest.cs +++ b/Examples/Core/ScissorTest.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class ScissorTest : IExample diff --git a/Examples/Core/ScreenRecording.cs b/Examples/Core/ScreenRecording.cs index 9652c5f..979a0be 100644 --- a/Examples/Core/ScreenRecording.cs +++ b/Examples/Core/ScreenRecording.cs @@ -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(); + if (output == null) + { + return Array.Empty(); + } + 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(); + } } } diff --git a/Examples/Core/SmoothPixelperfect.cs b/Examples/Core/SmoothPixelperfect.cs index d161d46..a197a57 100644 --- a/Examples/Core/SmoothPixelperfect.cs +++ b/Examples/Core/SmoothPixelperfect.cs @@ -16,10 +16,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class SmoothPixelPerfect : IExample diff --git a/Examples/Core/SplitScreen.cs b/Examples/Core/SplitScreen.cs index 828eac1..09fbf4f 100644 --- a/Examples/Core/SplitScreen.cs +++ b/Examples/Core/SplitScreen.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class SplitScreen : IExample diff --git a/Examples/Core/SplitScreen2D.cs b/Examples/Core/SplitScreen2D.cs index d09039e..45a14ef 100644 --- a/Examples/Core/SplitScreen2D.cs +++ b/Examples/Core/SplitScreen2D.cs @@ -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); diff --git a/Examples/Core/StorageValues.cs b/Examples/Core/StorageValues.cs index d64c358..746f3db 100644 --- a/Examples/Core/StorageValues.cs +++ b/Examples/Core/StorageValues.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class StorageValues : IExample diff --git a/Examples/Core/TextFileLoading.cs b/Examples/Core/TextFileLoading.cs index deb0efa..460b12e 100644 --- a/Examples/Core/TextFileLoading.cs +++ b/Examples/Core/TextFileLoading.cs @@ -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)); diff --git a/Examples/Core/UndoRedo.cs b/Examples/Core/UndoRedo.cs index 4428f21..77a960b 100644 --- a/Examples/Core/UndoRedo.cs +++ b/Examples/Core/UndoRedo.cs @@ -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, diff --git a/Examples/Core/ViewportScaling.cs b/Examples/Core/ViewportScaling.cs index b6324f0..615b832 100644 --- a/Examples/Core/ViewportScaling.cs +++ b/Examples/Core/ViewportScaling.cs @@ -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); diff --git a/Examples/Core/VrSimulator.cs b/Examples/Core/VrSimulator.cs index fe27700..671c714 100644 --- a/Examples/Core/VrSimulator.cs +++ b/Examples/Core/VrSimulator.cs @@ -13,10 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class VrSimulator : IExample diff --git a/Examples/Core/WindowFlags.cs b/Examples/Core/WindowFlags.cs index 2f82111..4589e14 100644 --- a/Examples/Core/WindowFlags.cs +++ b/Examples/Core/WindowFlags.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.ConfigFlags; namespace Examples.Core; diff --git a/Examples/Core/WindowLetterbox.cs b/Examples/Core/WindowLetterbox.cs index a9341de..0c57821 100644 --- a/Examples/Core/WindowLetterbox.cs +++ b/Examples/Core/WindowLetterbox.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class WindowLetterbox : IExample diff --git a/Examples/Core/WindowShouldClose.cs b/Examples/Core/WindowShouldClose.cs index b1d4ed5..3fead4a 100644 --- a/Examples/Core/WindowShouldClose.cs +++ b/Examples/Core/WindowShouldClose.cs @@ -13,10 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class WindowShouldClose : IExample diff --git a/Examples/Core/WorldScreen.cs b/Examples/Core/WorldScreen.cs index 57aa4e4..0ef0749 100644 --- a/Examples/Core/WorldScreen.cs +++ b/Examples/Core/WorldScreen.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Core; public partial class WorldScreen : IExample diff --git a/Examples/Models/AnimationBlendCustom.cs b/Examples/Models/AnimationBlendCustom.cs index 2bacd9e..2521aa6 100644 --- a/Examples/Models/AnimationBlendCustom.cs +++ b/Examples/Models/AnimationBlendCustom.cs @@ -24,9 +24,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Models; diff --git a/Examples/Models/AnimationBlending.cs b/Examples/Models/AnimationBlending.cs index eba664b..3f458c5 100644 --- a/Examples/Models/AnimationBlending.cs +++ b/Examples/Models/AnimationBlending.cs @@ -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 diff --git a/Examples/Models/AnimationGpuSkinning.cs b/Examples/Models/AnimationGpuSkinning.cs index f4e67bc..a32d1e6 100644 --- a/Examples/Models/AnimationGpuSkinning.cs +++ b/Examples/Models/AnimationGpuSkinning.cs @@ -18,9 +18,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class AnimationGpuSkinning : IExample diff --git a/Examples/Models/AnimationTiming.cs b/Examples/Models/AnimationTiming.cs index 8fff3c5..10374b4 100644 --- a/Examples/Models/AnimationTiming.cs +++ b/Examples/Models/AnimationTiming.cs @@ -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 diff --git a/Examples/Models/BasicVoxel.cs b/Examples/Models/BasicVoxel.cs index ae7b66d..fa83e42 100644 --- a/Examples/Models/BasicVoxel.cs +++ b/Examples/Models/BasicVoxel.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class BasicVoxel : IExample diff --git a/Examples/Models/BillboardDemo.cs b/Examples/Models/BillboardDemo.cs index 82c81a7..db4f878 100644 --- a/Examples/Models/BillboardDemo.cs +++ b/Examples/Models/BillboardDemo.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class BillboardDemo : IExample diff --git a/Examples/Models/BoneSocket.cs b/Examples/Models/BoneSocket.cs index 95dd488..9eccefc 100644 --- a/Examples/Models/BoneSocket.cs +++ b/Examples/Models/BoneSocket.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Models; diff --git a/Examples/Models/BoxCollisions.cs b/Examples/Models/BoxCollisions.cs index 65bb5bc..5a29436 100644 --- a/Examples/Models/BoxCollisions.cs +++ b/Examples/Models/BoxCollisions.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class BoxCollisions : IExample diff --git a/Examples/Models/CubicmapDemo.cs b/Examples/Models/CubicmapDemo.cs index cb4f5c8..8fac085 100644 --- a/Examples/Models/CubicmapDemo.cs +++ b/Examples/Models/CubicmapDemo.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class CubicmapDemo : IExample diff --git a/Examples/Models/Decals.cs b/Examples/Models/Decals.cs index 1e655ee..461f5ac 100644 --- a/Examples/Models/Decals.cs +++ b/Examples/Models/Decals.cs @@ -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; diff --git a/Examples/Models/DirectionalBillboard.cs b/Examples/Models/DirectionalBillboard.cs index f5439db..cf4f637 100644 --- a/Examples/Models/DirectionalBillboard.cs +++ b/Examples/Models/DirectionalBillboard.cs @@ -16,9 +16,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Models; diff --git a/Examples/Models/DynamicMesh.cs b/Examples/Models/DynamicMesh.cs index e9dae9f..0d37f9d 100644 --- a/Examples/Models/DynamicMesh.cs +++ b/Examples/Models/DynamicMesh.cs @@ -1,6 +1,3 @@ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class DynamicMesh : IExample diff --git a/Examples/Models/FirstPersonMaze.cs b/Examples/Models/FirstPersonMaze.cs index ac91600..83ae470 100644 --- a/Examples/Models/FirstPersonMaze.cs +++ b/Examples/Models/FirstPersonMaze.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public unsafe partial class FirstPersonMaze : IExample diff --git a/Examples/Models/GeometricShapes.cs b/Examples/Models/GeometricShapes.cs index 465264c..57baa1e 100644 --- a/Examples/Models/GeometricShapes.cs +++ b/Examples/Models/GeometricShapes.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class GeometricShapes : IExample diff --git a/Examples/Models/HeightmapDemo.cs b/Examples/Models/HeightmapDemo.cs index 74efd36..4f50927 100644 --- a/Examples/Models/HeightmapDemo.cs +++ b/Examples/Models/HeightmapDemo.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class HeightmapDemo : IExample diff --git a/Examples/Models/LoadingGltf.cs b/Examples/Models/LoadingGltf.cs index 865998a..76462d7 100644 --- a/Examples/Models/LoadingGltf.cs +++ b/Examples/Models/LoadingGltf.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class LoadingGltf : IExample diff --git a/Examples/Models/LoadingIqm.cs b/Examples/Models/LoadingIqm.cs index 7ccfc12..e5332a2 100644 --- a/Examples/Models/LoadingIqm.cs +++ b/Examples/Models/LoadingIqm.cs @@ -19,10 +19,6 @@ * ********************************************************************************************/ -using System.Numerics; -using System.Runtime.InteropServices; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class LoadingIqm : IExample diff --git a/Examples/Models/LoadingM3d.cs b/Examples/Models/LoadingM3d.cs index 343d24f..552f4f1 100644 --- a/Examples/Models/LoadingM3d.cs +++ b/Examples/Models/LoadingM3d.cs @@ -19,9 +19,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class LoadingM3d : IExample diff --git a/Examples/Models/LoadingVox.cs b/Examples/Models/LoadingVox.cs index 7b267ac..6945984 100644 --- a/Examples/Models/LoadingVox.cs +++ b/Examples/Models/LoadingVox.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; using Examples.Shared; diff --git a/Examples/Models/MeshDemo.cs b/Examples/Models/MeshDemo.cs index 98ef2f2..a869e3b 100644 --- a/Examples/Models/MeshDemo.cs +++ b/Examples/Models/MeshDemo.cs @@ -1,6 +1,3 @@ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class MeshDemo : IExample diff --git a/Examples/Models/MeshGeneration.cs b/Examples/Models/MeshGeneration.cs index 4415c90..705c90d 100644 --- a/Examples/Models/MeshGeneration.cs +++ b/Examples/Models/MeshGeneration.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class MeshGeneration : IExample diff --git a/Examples/Models/MeshPicking.cs b/Examples/Models/MeshPicking.cs index 3f62595..b85f2e5 100644 --- a/Examples/Models/MeshPicking.cs +++ b/Examples/Models/MeshPicking.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Models; diff --git a/Examples/Models/ModelCubeTexture.cs b/Examples/Models/ModelCubeTexture.cs index c2c702f..7d8b3f8 100644 --- a/Examples/Models/ModelCubeTexture.cs +++ b/Examples/Models/ModelCubeTexture.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class ModelCubeTexture : IExample diff --git a/Examples/Models/ModelLoading.cs b/Examples/Models/ModelLoading.cs index 9198ecc..a93b71c 100644 --- a/Examples/Models/ModelLoading.cs +++ b/Examples/Models/ModelLoading.cs @@ -26,9 +26,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class ModelLoading : IExample diff --git a/Examples/Models/OrthographicProjection.cs b/Examples/Models/OrthographicProjection.cs index 1cde4b5..e80505b 100644 --- a/Examples/Models/OrthographicProjection.cs +++ b/Examples/Models/OrthographicProjection.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class OrthographicProjection : IExample diff --git a/Examples/Models/PointRendering.cs b/Examples/Models/PointRendering.cs index 15cd2bf..a1ca73e 100644 --- a/Examples/Models/PointRendering.cs +++ b/Examples/Models/PointRendering.cs @@ -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)")] diff --git a/Examples/Models/RotatingCube.cs b/Examples/Models/RotatingCube.cs index c903d96..67f1132 100644 --- a/Examples/Models/RotatingCube.cs +++ b/Examples/Models/RotatingCube.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class RotatingCube : IExample diff --git a/Examples/Models/SkyboxDemo.cs b/Examples/Models/SkyboxDemo.cs index 8238eae..e808413 100644 --- a/Examples/Models/SkyboxDemo.cs +++ b/Examples/Models/SkyboxDemo.cs @@ -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)")] diff --git a/Examples/Models/SolarSystem.cs b/Examples/Models/SolarSystem.cs index 36c989f..5fc1939 100644 --- a/Examples/Models/SolarSystem.cs +++ b/Examples/Models/SolarSystem.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class SolarSystem : IExample diff --git a/Examples/Models/TesseractView.cs b/Examples/Models/TesseractView.cs index b5a1964..0e17a8b 100644 --- a/Examples/Models/TesseractView.cs +++ b/Examples/Models/TesseractView.cs @@ -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(); diff --git a/Examples/Models/WavingCubes.cs b/Examples/Models/WavingCubes.cs index 30a4442..9b1dbc2 100644 --- a/Examples/Models/WavingCubes.cs +++ b/Examples/Models/WavingCubes.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Models; public partial class WavingCubes : IExample diff --git a/Examples/Models/YawPitchRoll.cs b/Examples/Models/YawPitchRoll.cs index 3b26f34..b812945 100644 --- a/Examples/Models/YawPitchRoll.cs +++ b/Examples/Models/YawPitchRoll.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Models; diff --git a/Examples/Shaders/AsciiRendering.cs b/Examples/Shaders/AsciiRendering.cs index 7924c79..73487e9 100644 --- a/Examples/Shaders/AsciiRendering.cs +++ b/Examples/Shaders/AsciiRendering.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public partial class AsciiRendering : IExample diff --git a/Examples/Shaders/BasicLighting.cs b/Examples/Shaders/BasicLighting.cs index 13ef4e0..4eafc35 100644 --- a/Examples/Shaders/BasicLighting.cs +++ b/Examples/Shaders/BasicLighting.cs @@ -20,8 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using Examples.Shared; namespace Examples.Shaders; diff --git a/Examples/Shaders/BasicPbr.cs b/Examples/Shaders/BasicPbr.cs index e29ce26..accfc03 100644 --- a/Examples/Shaders/BasicPbr.cs +++ b/Examples/Shaders/BasicPbr.cs @@ -19,9 +19,7 @@ * ********************************************************************************************/ -using System.Numerics; using Examples.Shared; -using static Raylib_cs.Raylib; namespace Examples.Shaders; diff --git a/Examples/Shaders/CelShading.cs b/Examples/Shaders/CelShading.cs index c65153f..5acbbc9 100644 --- a/Examples/Shaders/CelShading.cs +++ b/Examples/Shaders/CelShading.cs @@ -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; diff --git a/Examples/Shaders/ColorCorrection.cs b/Examples/Shaders/ColorCorrection.cs index c70dce5..322dd15 100644 --- a/Examples/Shaders/ColorCorrection.cs +++ b/Examples/Shaders/ColorCorrection.cs @@ -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) diff --git a/Examples/Shaders/CustomUniform.cs b/Examples/Shaders/CustomUniform.cs index 44b3159..041386c 100644 --- a/Examples/Shaders/CustomUniform.cs +++ b/Examples/Shaders/CustomUniform.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class CustomUniform : IExample diff --git a/Examples/Shaders/DeferredRendering.cs b/Examples/Shaders/DeferredRendering.cs index f6af204..93ff23f 100644 --- a/Examples/Shaders/DeferredRendering.cs +++ b/Examples/Shaders/DeferredRendering.cs @@ -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(); diff --git a/Examples/Shaders/DepthRendering.cs b/Examples/Shaders/DepthRendering.cs index 51bb937..f323436 100644 --- a/Examples/Shaders/DepthRendering.cs +++ b/Examples/Shaders/DepthRendering.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class DepthRendering : IExample diff --git a/Examples/Shaders/Eratosthenes.cs b/Examples/Shaders/Eratosthenes.cs index d97ed6d..7f8876c 100644 --- a/Examples/Shaders/Eratosthenes.cs +++ b/Examples/Shaders/Eratosthenes.cs @@ -27,9 +27,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class Eratosthenes : IExample diff --git a/Examples/Shaders/Fog.cs b/Examples/Shaders/Fog.cs index b10f3f5..f31f264 100644 --- a/Examples/Shaders/Fog.cs +++ b/Examples/Shaders/Fog.cs @@ -20,8 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; using Examples.Shared; diff --git a/Examples/Shaders/GameOfLife.cs b/Examples/Shaders/GameOfLife.cs index 6f62950..13bf679 100644 --- a/Examples/Shaders/GameOfLife.cs +++ b/Examples/Shaders/GameOfLife.cs @@ -18,10 +18,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public partial class GameOfLife : IExample @@ -186,15 +182,30 @@ public partial class GameOfLife : IExample var centerX = offsetX + (windowWidth / 2.0f) / zoom; var centerY = offsetY + (windowHeight / 2.0f) / zoom; - if (buttonZoomIn || (mouseWheelMove > 0.0f)) zoom *= 2; - if ((buttonZomOut || (mouseWheelMove < 0.0f)) && (zoom > 1)) zoom /= 2; + if (buttonZoomIn || (mouseWheelMove > 0.0f)) + { + zoom *= 2; + } + + if ((buttonZomOut || (mouseWheelMove < 0.0f)) && (zoom > 1)) + { + zoom /= 2; + } + offsetX = centerX - (windowWidth / 2.0f) / zoom; offsetY = centerY - (windowHeight / 2.0f) / zoom; } // Change speed: number of frames per step - if (buttonFaster && framesPerStep > 1) framesPerStep--; - if (buttonSlower) framesPerStep++; + if (buttonFaster && framesPerStep > 1) + { + framesPerStep--; + } + + if (buttonSlower) + { + framesPerStep++; + } // Mouse management if ((mode == InteractionMode.Run) || (mode == InteractionMode.Pause)) @@ -216,8 +227,15 @@ public partial class GameOfLife : IExample var offsetDecimalY = offsetY - MathF.Floor(offsetY); var sizeInWorldX = (int)(MathF.Ceiling((windowWidth + offsetDecimalX * zoom) / zoom)); var sizeInWorldY = (int)(MathF.Ceiling((windowHeight + offsetDecimalY * zoom) / zoom)); - if (offsetX + sizeInWorldX >= worldWidth) sizeInWorldX = worldWidth - (int)MathF.Floor(offsetX); - if (offsetY + sizeInWorldY >= worldHeight) sizeInWorldY = worldHeight - (int)MathF.Floor(offsetY); + if (offsetX + sizeInWorldX >= worldWidth) + { + sizeInWorldX = worldWidth - (int)MathF.Floor(offsetX); + } + + if (offsetY + sizeInWorldY >= worldHeight) + { + sizeInWorldY = worldHeight - (int)MathF.Floor(offsetY); + } // Create image to draw if not created yet if (!imageToDrawValid) @@ -242,9 +260,21 @@ public partial class GameOfLife : IExample { var mouseX = (int)(mousePosition.X + offsetDecimalX * zoom) / zoom; var mouseY = (int)(mousePosition.Y + offsetDecimalY * zoom) / zoom; - if (mouseX >= sizeInWorldX) mouseX = sizeInWorldX - 1; - if (mouseY >= sizeInWorldY) mouseY = sizeInWorldY - 1; - if (firstColor == -1) firstColor = (GetImageColor(imageToDraw, mouseX, mouseY).R < 5) ? 0 : 1; + if (mouseX >= sizeInWorldX) + { + mouseX = sizeInWorldX - 1; + } + + if (mouseY >= sizeInWorldY) + { + mouseY = sizeInWorldY - 1; + } + + if (firstColor == -1) + { + firstColor = (GetImageColor(imageToDraw, mouseX, mouseY).R < 5) ? 0 : 1; + } + var prevColor = (GetImageColor(imageToDraw, mouseX, mouseY).R < 5) ? 0 : 1; ImageDrawPixel(ref imageToDraw, mouseX, mouseY, (firstColor != 0) ? Color.Black : Color.RayWhite); @@ -258,7 +288,10 @@ public partial class GameOfLife : IExample ); } } - else firstColor = -1; + else + { + firstColor = -1; + } } // Load selected preset @@ -306,7 +339,10 @@ public partial class GameOfLife : IExample { for (var y = 0; y < pattern.Height; y++) { - if (GetRandomValue(0, 100) < 15) ImageDrawPixel(ref pattern, x, y, Color.Black); + if (GetRandomValue(0, 100) < 15) + { + ImageDrawPixel(ref pattern, x, y, Color.Black); + } } } UpdateTextureRec( @@ -326,10 +362,25 @@ public partial class GameOfLife : IExample } // Check window draw inside world limits - if (offsetX < 0) offsetX = 0; - if (offsetY < 0) offsetY = 0; - if (offsetX > worldWidth - (float)windowWidth / zoom) offsetX = worldWidth - (float)windowWidth / zoom; - if (offsetY > worldHeight - (float)windowHeight / zoom) offsetY = worldHeight - (float)windowHeight / zoom; + if (offsetX < 0) + { + offsetX = 0; + } + + if (offsetY < 0) + { + offsetY = 0; + } + + if (offsetX > worldWidth - (float)windowWidth / zoom) + { + offsetX = worldWidth - (float)windowWidth / zoom; + } + + if (offsetY > worldHeight - (float)windowHeight / zoom) + { + offsetY = worldHeight - (float)windowHeight / zoom; + } // Rectangles for drawing texture portion to screen var textureSourceToScreen = new Rectangle(offsetX, offsetY, (float)windowWidth / zoom, (float)windowHeight / zoom); diff --git a/Examples/Shaders/HotReloading.cs b/Examples/Shaders/HotReloading.cs index 6390e68..dc716d3 100644 --- a/Examples/Shaders/HotReloading.cs +++ b/Examples/Shaders/HotReloading.cs @@ -16,10 +16,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class HotReloading : IExample diff --git a/Examples/Shaders/HybridRender.cs b/Examples/Shaders/HybridRender.cs index 4b3ed79..888a974 100644 --- a/Examples/Shaders/HybridRender.cs +++ b/Examples/Shaders/HybridRender.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class HybridRender : IExample diff --git a/Examples/Shaders/JuliaSet.cs b/Examples/Shaders/JuliaSet.cs index 8e146e9..e63437f 100644 --- a/Examples/Shaders/JuliaSet.cs +++ b/Examples/Shaders/JuliaSet.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class JuliaSet : IExample diff --git a/Examples/Shaders/LightmapRendering.cs b/Examples/Shaders/LightmapRendering.cs index 140f013..32bb7cf 100644 --- a/Examples/Shaders/LightmapRendering.cs +++ b/Examples/Shaders/LightmapRendering.cs @@ -20,8 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Rlgl; namespace Examples.Shaders; diff --git a/Examples/Shaders/MandelbrotSet.cs b/Examples/Shaders/MandelbrotSet.cs index 66b73a8..0e2c8ac 100644 --- a/Examples/Shaders/MandelbrotSet.cs +++ b/Examples/Shaders/MandelbrotSet.cs @@ -21,10 +21,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public partial class MandelbrotSet : IExample @@ -122,12 +118,30 @@ public partial class MandelbrotSet : IExample IsKeyPressed(KeyboardKey.Six)) { var interestIndex = 0; - if (IsKeyPressed(KeyboardKey.One)) interestIndex = 0; - else if (IsKeyPressed(KeyboardKey.Two)) interestIndex = 1; - else if (IsKeyPressed(KeyboardKey.Three)) interestIndex = 2; - else if (IsKeyPressed(KeyboardKey.Four)) interestIndex = 3; - else if (IsKeyPressed(KeyboardKey.Five)) interestIndex = 4; - else if (IsKeyPressed(KeyboardKey.Six)) interestIndex = 5; + if (IsKeyPressed(KeyboardKey.One)) + { + interestIndex = 0; + } + else if (IsKeyPressed(KeyboardKey.Two)) + { + interestIndex = 1; + } + else if (IsKeyPressed(KeyboardKey.Three)) + { + interestIndex = 2; + } + else if (IsKeyPressed(KeyboardKey.Four)) + { + interestIndex = 3; + } + else if (IsKeyPressed(KeyboardKey.Five)) + { + interestIndex = 4; + } + else if (IsKeyPressed(KeyboardKey.Six)) + { + interestIndex = 5; + } offset[0] = pointsOfInterest[interestIndex][0]; offset[1] = pointsOfInterest[interestIndex][1]; @@ -144,7 +158,10 @@ public partial class MandelbrotSet : IExample updateShader = true; } - if (IsKeyPressed(KeyboardKey.F1)) showControls = !showControls; // Toggle whether or not to show controls + if (IsKeyPressed(KeyboardKey.F1)) + { + showControls = !showControls; // Toggle whether or not to show controls + } // Change number of max iterations with UP and DOWN keys // WARNING: Increasing the number of max iterations greatly impacts performance diff --git a/Examples/Shaders/MeshInstancing.cs b/Examples/Shaders/MeshInstancing.cs index a639530..5beb294 100644 --- a/Examples/Shaders/MeshInstancing.cs +++ b/Examples/Shaders/MeshInstancing.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using Examples.Shared; namespace Examples.Shaders; diff --git a/Examples/Shaders/ModelShader.cs b/Examples/Shaders/ModelShader.cs index 033b530..455777c 100644 --- a/Examples/Shaders/ModelShader.cs +++ b/Examples/Shaders/ModelShader.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class ModelShader : IExample diff --git a/Examples/Shaders/MultiSample2d.cs b/Examples/Shaders/MultiSample2d.cs index 5375cf2..084d95b 100644 --- a/Examples/Shaders/MultiSample2d.cs +++ b/Examples/Shaders/MultiSample2d.cs @@ -20,8 +20,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class MultiSample2d : IExample diff --git a/Examples/Shaders/NormalmapRendering.cs b/Examples/Shaders/NormalmapRendering.cs index 0db18d9..822ee1f 100644 --- a/Examples/Shaders/NormalmapRendering.cs +++ b/Examples/Shaders/NormalmapRendering.cs @@ -18,8 +18,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shaders; diff --git a/Examples/Shaders/PaletteSwitch.cs b/Examples/Shaders/PaletteSwitch.cs index bed75e4..c99c206 100644 --- a/Examples/Shaders/PaletteSwitch.cs +++ b/Examples/Shaders/PaletteSwitch.cs @@ -22,8 +22,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class PaletteSwitch : IExample diff --git a/Examples/Shaders/PostProcessing.cs b/Examples/Shaders/PostProcessing.cs index 9df3515..4af13f7 100644 --- a/Examples/Shaders/PostProcessing.cs +++ b/Examples/Shaders/PostProcessing.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class PostProcessing : IExample diff --git a/Examples/Shaders/Raymarching.cs b/Examples/Shaders/Raymarching.cs index e521b6d..da69600 100644 --- a/Examples/Shaders/Raymarching.cs +++ b/Examples/Shaders/Raymarching.cs @@ -16,8 +16,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.ConfigFlags; namespace Examples.Shaders; diff --git a/Examples/Shaders/RlglCompute.cs b/Examples/Shaders/RlglCompute.cs index 1f67537..1008623 100644 --- a/Examples/Shaders/RlglCompute.cs +++ b/Examples/Shaders/RlglCompute.cs @@ -18,11 +18,9 @@ * ********************************************************************************************/ -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; -using static Raylib_cs.Raylib; namespace Examples.Shaders; diff --git a/Examples/Shaders/RoundedRectangle.cs b/Examples/Shaders/RoundedRectangle.cs index 8888b59..ed62f49 100644 --- a/Examples/Shaders/RoundedRectangle.cs +++ b/Examples/Shaders/RoundedRectangle.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class RoundedRectangle : IExample diff --git a/Examples/Shaders/ShadowmapRendering.cs b/Examples/Shaders/ShadowmapRendering.cs index 266c0c6..fe9885f 100644 --- a/Examples/Shaders/ShadowmapRendering.cs +++ b/Examples/Shaders/ShadowmapRendering.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; using static Raylib_cs.Rlgl; diff --git a/Examples/Shaders/ShapesTextures.cs b/Examples/Shaders/ShapesTextures.cs index c0a5eef..a4a853e 100644 --- a/Examples/Shaders/ShapesTextures.cs +++ b/Examples/Shaders/ShapesTextures.cs @@ -20,9 +20,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class ShapesTextures : IExample diff --git a/Examples/Shaders/SimpleMask.cs b/Examples/Shaders/SimpleMask.cs index 032aa90..d008a76 100644 --- a/Examples/Shaders/SimpleMask.cs +++ b/Examples/Shaders/SimpleMask.cs @@ -22,8 +22,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shaders; diff --git a/Examples/Shaders/Spotlight.cs b/Examples/Shaders/Spotlight.cs index b8e37c4..4899607 100644 --- a/Examples/Shaders/Spotlight.cs +++ b/Examples/Shaders/Spotlight.cs @@ -30,10 +30,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class Spotlight : IExample diff --git a/Examples/Shaders/TextureDrawing.cs b/Examples/Shaders/TextureDrawing.cs index 1d70b32..3ea2c13 100644 --- a/Examples/Shaders/TextureDrawing.cs +++ b/Examples/Shaders/TextureDrawing.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class TextureDrawing : IExample diff --git a/Examples/Shaders/TextureOutline.cs b/Examples/Shaders/TextureOutline.cs index 63cf304..9425f6b 100644 --- a/Examples/Shaders/TextureOutline.cs +++ b/Examples/Shaders/TextureOutline.cs @@ -18,8 +18,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class TextureOutline : IExample diff --git a/Examples/Shaders/TextureTiling.cs b/Examples/Shaders/TextureTiling.cs index 8b636d3..f6a2f0c 100644 --- a/Examples/Shaders/TextureTiling.cs +++ b/Examples/Shaders/TextureTiling.cs @@ -17,9 +17,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class TextureTiling : IExample diff --git a/Examples/Shaders/TextureWaves.cs b/Examples/Shaders/TextureWaves.cs index bb49258..57a8a49 100644 --- a/Examples/Shaders/TextureWaves.cs +++ b/Examples/Shaders/TextureWaves.cs @@ -22,8 +22,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class TextureWaves : IExample diff --git a/Examples/Shaders/VertexDisplacement.cs b/Examples/Shaders/VertexDisplacement.cs index 4d78c62..20dd0cb 100644 --- a/Examples/Shaders/VertexDisplacement.cs +++ b/Examples/Shaders/VertexDisplacement.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Rlgl; namespace Examples.Shaders; diff --git a/Examples/Shaders/WriteDepth.cs b/Examples/Shaders/WriteDepth.cs index e2c917d..0a099f0 100644 --- a/Examples/Shaders/WriteDepth.cs +++ b/Examples/Shaders/WriteDepth.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shaders; public class WriteDepth : IExample diff --git a/Examples/Shapes/BallPhysics.cs b/Examples/Shapes/BallPhysics.cs index 4a7739c..cfbe66e 100644 --- a/Examples/Shapes/BallPhysics.cs +++ b/Examples/Shapes/BallPhysics.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shapes; @@ -146,7 +143,10 @@ public partial class BallPhysics : IExample { for (int i = 0; i < ballCount; i++) { - if (!balls[i].grabbed) balls[i].speed = Vector2Add(balls[i].speed, Vector2Scale(windowPositionDelta, 10.0f)); + if (!balls[i].grabbed) + { + balls[i].speed = Vector2Add(balls[i].speed, Vector2Scale(windowPositionDelta, 10.0f)); + } } } @@ -155,7 +155,10 @@ public partial class BallPhysics : IExample { for (int i = 0; i < ballCount; i++) { - if (!balls[i].grabbed) balls[i].speed = new Vector2(GetRandomValue(-2000, 2000), GetRandomValue(-2000, 2000)); + if (!balls[i].grabbed) + { + balls[i].speed = new Vector2(GetRandomValue(-2000, 2000), GetRandomValue(-2000, 2000)); + } } } diff --git a/Examples/Shapes/BasicShapes.cs b/Examples/Shapes/BasicShapes.cs index 57f425c..7f0b02c 100644 --- a/Examples/Shapes/BasicShapes.cs +++ b/Examples/Shapes/BasicShapes.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class BasicShapes : IExample diff --git a/Examples/Shapes/BouncingBall.cs b/Examples/Shapes/BouncingBall.cs index eca2249..2129510 100644 --- a/Examples/Shapes/BouncingBall.cs +++ b/Examples/Shapes/BouncingBall.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class BouncingBall : IExample diff --git a/Examples/Shapes/BulletHell.cs b/Examples/Shapes/BulletHell.cs index 5fdc9fd..09660f9 100644 --- a/Examples/Shapes/BulletHell.cs +++ b/Examples/Shapes/BulletHell.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class BulletHell : IExample @@ -167,13 +163,40 @@ public partial class BulletHell : IExample } // Input logic - if ((IsKeyPressed(KeyboardKey.Right) || IsKeyPressed(KeyboardKey.D)) && (bulletRows < 359)) bulletRows++; - if ((IsKeyPressed(KeyboardKey.Left) || IsKeyPressed(KeyboardKey.A)) && (bulletRows > 1)) bulletRows--; - if (IsKeyPressed(KeyboardKey.Up) || IsKeyPressed(KeyboardKey.W)) bulletSpeed += 0.25f; - if ((IsKeyPressed(KeyboardKey.Down) || IsKeyPressed(KeyboardKey.S)) && (bulletSpeed > 0.50f)) bulletSpeed -= 0.25f; - if (IsKeyPressed(KeyboardKey.Z) && (spawnCooldown > 1)) spawnCooldown--; - if (IsKeyPressed(KeyboardKey.X)) spawnCooldown++; - if (IsKeyPressed(KeyboardKey.Enter)) drawInPerformanceMode = !drawInPerformanceMode; + if ((IsKeyPressed(KeyboardKey.Right) || IsKeyPressed(KeyboardKey.D)) && (bulletRows < 359)) + { + bulletRows++; + } + + if ((IsKeyPressed(KeyboardKey.Left) || IsKeyPressed(KeyboardKey.A)) && (bulletRows > 1)) + { + bulletRows--; + } + + if (IsKeyPressed(KeyboardKey.Up) || IsKeyPressed(KeyboardKey.W)) + { + bulletSpeed += 0.25f; + } + + if ((IsKeyPressed(KeyboardKey.Down) || IsKeyPressed(KeyboardKey.S)) && (bulletSpeed > 0.50f)) + { + bulletSpeed -= 0.25f; + } + + if (IsKeyPressed(KeyboardKey.Z) && (spawnCooldown > 1)) + { + spawnCooldown--; + } + + if (IsKeyPressed(KeyboardKey.X)) + { + spawnCooldown++; + } + + if (IsKeyPressed(KeyboardKey.Enter)) + { + drawInPerformanceMode = !drawInPerformanceMode; + } if (IsKeyDown(KeyboardKey.Space)) { @@ -244,10 +267,16 @@ public partial class BulletHell : IExample DrawText("- C: Clear bullets", 40, 140, 10, Color.LightGray); DrawRectangle(610, 10, 170, 30, new Color(0, 0, 0, 200)); - if (drawInPerformanceMode) DrawText("Draw method: DrawTexture(*)", 620, 20, 10, Color.Green); - else DrawText("Draw method: DrawCircle(*)", 620, 20, 10, Color.Red); + if (drawInPerformanceMode) + { + DrawText("Draw method: DrawTexture(*)", 620, 20, 10, Color.Green); + } + else + { + DrawText("Draw method: DrawCircle(*)", 620, 20, 10, Color.Red); + } - DrawRectangle(135, 410, 530, 30, new Color(0, 0, 0, 200)); + DrawRectangle(135, 410, 530, 30, new Color(0, 0, 0, 200)); DrawText($"[ FPS: {GetFPS()}, Bullets: {bulletCount - bulletDisabledCount}, Rows: {bulletRows}, Bullet speed: {bulletSpeed:F2}, Angle increment per frame: {angleIncrement}, Cooldown: {spawnCooldown:F0} ]", 155, 420, 10, Color.Green); diff --git a/Examples/Shapes/ClockOfClocks.cs b/Examples/Shapes/ClockOfClocks.cs index c80d5e4..0a329f0 100644 --- a/Examples/Shapes/ClockOfClocks.cs +++ b/Examples/Shapes/ClockOfClocks.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; // Required for: Lerp(), Clamp() namespace Examples.Shapes; @@ -113,9 +110,20 @@ public partial class ClockOfClocks : IExample dstAngles[digit, cell] = digitAngles[clockDigits[digit] - '0', cell]; // Quick exception for 12h mode - if ((digit == 0) && (hourMode == 12) && (clockDigits[0] == '0')) dstAngles[digit, cell] = ZZ; - if (srcAngles[digit, cell].X > dstAngles[digit, cell].X) srcAngles[digit, cell].X -= 360.0f; - if (srcAngles[digit, cell].Y > dstAngles[digit, cell].Y) srcAngles[digit, cell].Y -= 360.0f; + if ((digit == 0) && (hourMode == 12) && (clockDigits[0] == '0')) + { + dstAngles[digit, cell] = ZZ; + } + + if (srcAngles[digit, cell].X > dstAngles[digit, cell].X) + { + srcAngles[digit, cell].X -= 360.0f; + } + + if (srcAngles[digit, cell].Y > dstAngles[digit, cell].Y) + { + srcAngles[digit, cell].Y -= 360.0f; + } } } @@ -146,7 +154,10 @@ public partial class ClockOfClocks : IExample } // Handle input - if (IsKeyPressed(KeyboardKey.Space)) hourMode = 36 - hourMode; // Toggle between 12 and 24 hour mode with space + if (IsKeyPressed(KeyboardKey.Space)) + { + hourMode = 36 - hourMode; // Toggle between 12 and 24 hour mode with space + } //---------------------------------------------------------------------------------- // Draw diff --git a/Examples/Shapes/CollisionArea.cs b/Examples/Shapes/CollisionArea.cs index 6b01cd5..9b326f5 100644 --- a/Examples/Shapes/CollisionArea.cs +++ b/Examples/Shapes/CollisionArea.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class CollisionArea : IExample diff --git a/Examples/Shapes/ColorsPalette.cs b/Examples/Shapes/ColorsPalette.cs index 9ada68a..98d4dc0 100644 --- a/Examples/Shapes/ColorsPalette.cs +++ b/Examples/Shapes/ColorsPalette.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class ColorsPalette : IExample diff --git a/Examples/Shapes/DashedLine.cs b/Examples/Shapes/DashedLine.cs index 5d50c1e..30eb773 100644 --- a/Examples/Shapes/DashedLine.cs +++ b/Examples/Shapes/DashedLine.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DashedLine : IExample @@ -59,15 +56,32 @@ public partial class DashedLine : IExample lineEndPosition = GetMousePosition(); // Line endpoint follows the mouse // Change Dash Length (UP/DOWN arrows) - if (IsKeyDown(KeyboardKey.Up)) dashLength += 1.0f; - if (IsKeyDown(KeyboardKey.Down) && dashLength > 1.0f) dashLength -= 1.0f; + if (IsKeyDown(KeyboardKey.Up)) + { + dashLength += 1.0f; + } + + if (IsKeyDown(KeyboardKey.Down) && dashLength > 1.0f) + { + dashLength -= 1.0f; + } // Change Space Length (LEFT/RIGHT arrows) - if (IsKeyDown(KeyboardKey.Right)) blankLength += 1.0f; - if (IsKeyDown(KeyboardKey.Left) && blankLength > 1.0f) blankLength -= 1.0f; + if (IsKeyDown(KeyboardKey.Right)) + { + blankLength += 1.0f; + } + + if (IsKeyDown(KeyboardKey.Left) && blankLength > 1.0f) + { + blankLength -= 1.0f; + } // Cycle through colors ('C' key) - if (IsKeyPressed(KeyboardKey.C)) colorIndex = (colorIndex + 1)%lineColors.Length; + if (IsKeyPressed(KeyboardKey.C)) + { + colorIndex = (colorIndex + 1)%lineColors.Length; + } //---------------------------------------------------------------------------------- // Draw diff --git a/Examples/Shapes/DigitalClock.cs b/Examples/Shapes/DigitalClock.cs index 46981e4..b213f03 100644 --- a/Examples/Shapes/DigitalClock.cs +++ b/Examples/Shapes/DigitalClock.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DigitalClock : IExample @@ -92,8 +88,14 @@ public partial class DigitalClock : IExample if (IsKeyPressed(KeyboardKey.Space)) { // Toggle clock mode - if (clockMode == CLOCK_DIGITAL) clockMode = CLOCK_ANALOG; - else if (clockMode == CLOCK_ANALOG) clockMode = CLOCK_DIGITAL; + if (clockMode == CLOCK_DIGITAL) + { + clockMode = CLOCK_ANALOG; + } + else if (clockMode == CLOCK_ANALOG) + { + clockMode = CLOCK_DIGITAL; + } } UpdateClock(); // Update clock required data: value and angle @@ -106,7 +108,10 @@ public partial class DigitalClock : IExample ClearBackground(Color.RayWhite); // Draw clock in selected mode - if (clockMode == CLOCK_ANALOG) DrawClockAnalog(clock, new Vector2(400, 240)); + if (clockMode == CLOCK_ANALOG) + { + DrawClockAnalog(clock, new Vector2(400, 240)); + } else if (clockMode == CLOCK_DIGITAL) { DrawClockDigital(clock, new Vector2(30, 60)); diff --git a/Examples/Shapes/DoublePendulum.cs b/Examples/Shapes/DoublePendulum.cs index e6ba7ef..7013781 100644 --- a/Examples/Shapes/DoublePendulum.cs +++ b/Examples/Shapes/DoublePendulum.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DoublePendulum : IExample diff --git a/Examples/Shapes/DrawCircleSector.cs b/Examples/Shapes/DrawCircleSector.cs index 2f593a8..0364d7f 100644 --- a/Examples/Shapes/DrawCircleSector.cs +++ b/Examples/Shapes/DrawCircleSector.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DrawCircleSector : IExample @@ -106,16 +102,30 @@ public partial class DrawCircleSector : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/DrawRectangleRounded.cs b/Examples/Shapes/DrawRectangleRounded.cs index 780c00e..c2c564c 100644 --- a/Examples/Shapes/DrawRectangleRounded.cs +++ b/Examples/Shapes/DrawRectangleRounded.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DrawRectangleRounded : IExample @@ -119,27 +117,51 @@ public partial class DrawRectangleRounded : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiCheckBox(Rectangle bounds, string text, ref bool active) { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/DrawRing.cs b/Examples/Shapes/DrawRing.cs index cb4f5a3..49e4fcb 100644 --- a/Examples/Shapes/DrawRing.cs +++ b/Examples/Shapes/DrawRing.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class DrawRing : IExample @@ -149,27 +145,51 @@ public partial class DrawRing : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiCheckBox(Rectangle bounds, string text, ref bool active) { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/EasingsBallAnim.cs b/Examples/Shapes/EasingsBallAnim.cs index 5aae342..28c2df6 100644 --- a/Examples/Shapes/EasingsBallAnim.cs +++ b/Examples/Shapes/EasingsBallAnim.cs @@ -13,7 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; using Examples.Shared; namespace Examples.Shapes; diff --git a/Examples/Shapes/EasingsBoxAnim.cs b/Examples/Shapes/EasingsBoxAnim.cs index 6ce381e..9b5d935 100644 --- a/Examples/Shapes/EasingsBoxAnim.cs +++ b/Examples/Shapes/EasingsBoxAnim.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using Examples.Shared; namespace Examples.Shapes; diff --git a/Examples/Shapes/EasingsRectangleArray.cs b/Examples/Shapes/EasingsRectangleArray.cs index f660c0b..a4c9844 100644 --- a/Examples/Shapes/EasingsRectangleArray.cs +++ b/Examples/Shapes/EasingsRectangleArray.cs @@ -16,8 +16,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using Examples.Shared; namespace Examples.Shapes; diff --git a/Examples/Shapes/EasingsTestbed.cs b/Examples/Shapes/EasingsTestbed.cs index 7c864d7..c0a7798 100644 --- a/Examples/Shapes/EasingsTestbed.cs +++ b/Examples/Shapes/EasingsTestbed.cs @@ -15,10 +15,7 @@ * ********************************************************************************************/ -using System; -using System.Numerics; using Examples.Shared; -using static Raylib_cs.Raylib; namespace Examples.Shapes; @@ -112,19 +109,31 @@ public partial class EasingsTestbed : IExample { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KeyboardKey.T)) boundedT = !boundedT; + if (IsKeyPressed(KeyboardKey.T)) + { + boundedT = !boundedT; + } // Choose easing for the X axis if (IsKeyPressed(KeyboardKey.Right)) { easingX++; - if (easingX > EASING_NONE) easingX = 0; + if (easingX > EASING_NONE) + { + easingX = 0; + } } else if (IsKeyPressed(KeyboardKey.Left)) { - if (easingX == 0) easingX = EASING_NONE; - else easingX--; + if (easingX == 0) + { + easingX = EASING_NONE; + } + else + { + easingX--; + } } // Choose easing for the Y axis @@ -132,20 +141,41 @@ public partial class EasingsTestbed : IExample { easingY++; - if (easingY > EASING_NONE) easingY = 0; + if (easingY > EASING_NONE) + { + easingY = 0; + } } else if (IsKeyPressed(KeyboardKey.Up)) { - if (easingY == 0) easingY = EASING_NONE; - else easingY--; + if (easingY == 0) + { + easingY = EASING_NONE; + } + else + { + easingY--; + } } // Change d (duration) value - if (IsKeyPressed(KeyboardKey.W) && (d < D_MAX - D_STEP)) d += D_STEP; - else if (IsKeyPressed(KeyboardKey.Q) && (d > D_MIN + D_STEP)) d -= D_STEP; + if (IsKeyPressed(KeyboardKey.W) && (d < D_MAX - D_STEP)) + { + d += D_STEP; + } + else if (IsKeyPressed(KeyboardKey.Q) && (d > D_MIN + D_STEP)) + { + d -= D_STEP; + } - if (IsKeyDown(KeyboardKey.S) && (d < D_MAX - D_STEP_FINE)) d += D_STEP_FINE; - else if (IsKeyDown(KeyboardKey.A) && (d > D_MIN + D_STEP_FINE)) d -= D_STEP_FINE; + if (IsKeyDown(KeyboardKey.S) && (d < D_MAX - D_STEP_FINE)) + { + d += D_STEP_FINE; + } + else if (IsKeyDown(KeyboardKey.A) && (d > D_MIN + D_STEP_FINE)) + { + d -= D_STEP_FINE; + } // Play, pause and restart controls if (IsKeyPressed(KeyboardKey.Space) || IsKeyPressed(KeyboardKey.T) || @@ -161,7 +191,10 @@ public partial class EasingsTestbed : IExample paused = true; } - if (IsKeyPressed(KeyboardKey.Enter)) paused = !paused; + if (IsKeyPressed(KeyboardKey.Enter)) + { + paused = !paused; + } // Movement computation if (!paused && ((boundedT && t < d) || !boundedT)) diff --git a/Examples/Shapes/EllipseCollision.cs b/Examples/Shapes/EllipseCollision.cs index 6647efe..c73ca3e 100644 --- a/Examples/Shapes/EllipseCollision.cs +++ b/Examples/Shapes/EllipseCollision.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class EllipseCollision : IExample diff --git a/Examples/Shapes/FollowingEyes.cs b/Examples/Shapes/FollowingEyes.cs index cea7b62..bf208f3 100644 --- a/Examples/Shapes/FollowingEyes.cs +++ b/Examples/Shapes/FollowingEyes.cs @@ -13,11 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using Raylib_cs; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class FollowingEyes : IExample diff --git a/Examples/Shapes/HilbertCurve.cs b/Examples/Shapes/HilbertCurve.cs index 94d80cf..3e1f31c 100644 --- a/Examples/Shapes/HilbertCurve.cs +++ b/Examples/Shapes/HilbertCurve.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class HilbertCurve : IExample @@ -64,8 +61,14 @@ public partial class HilbertCurve : IExample { hilbertPath = LoadHilbertPath(order, size, out strokeCount); - if (animate) counter = 0; - else counter = strokeCount; + if (animate) + { + counter = 0; + } + else + { + counter = strokeCount; + } prevOrder = order; prevSize = (int)size; @@ -190,11 +193,21 @@ public partial class HilbertCurve : IExample { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiSpinner(Rectangle bounds, string text, ref int value, int minValue, int maxValue) @@ -204,8 +217,15 @@ public partial class HilbertCurve : IExample Rectangle right = new Rectangle(bounds.X + bounds.Width - bounds.Height, bounds.Y, bounds.Height, bounds.Height); Rectangle mid = new Rectangle(bounds.X + bounds.Height, bounds.Y, bounds.Width - 2 * bounds.Height, bounds.Height); - if (CheckCollisionPointRec(mouse, left) && IsMouseButtonPressed(MouseButton.Left) && value > minValue) value--; - if (CheckCollisionPointRec(mouse, right) && IsMouseButtonPressed(MouseButton.Left) && value < maxValue) value++; + if (CheckCollisionPointRec(mouse, left) && IsMouseButtonPressed(MouseButton.Left) && value > minValue) + { + value--; + } + + if (CheckCollisionPointRec(mouse, right) && IsMouseButtonPressed(MouseButton.Left) && value < maxValue) + { + value++; + } DrawRectangleRec(mid, Color.RayWhite); DrawRectangleLinesEx(mid, 1, Color.Gray); @@ -217,7 +237,10 @@ public partial class HilbertCurve : IExample DrawText("+", (int)(right.X + right.Width / 2 - 3), (int)(right.Y + right.Height / 2 - 5), 10, Color.DarkGray); string vs = value.ToString(); DrawText(vs, (int)(mid.X + mid.Width / 2 - MeasureText(vs, 10) / 2), (int)(mid.Y + mid.Height / 2 - 5), 10, Color.DarkGray); - if (text != null) DrawText(text, (int)bounds.X - MeasureText(text, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (text != null) + { + DrawText(text, (int)bounds.X - MeasureText(text, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiSlider(Rectangle bounds, string textLeft, string textRight, ref float value, float minValue, float maxValue) @@ -227,8 +250,15 @@ public partial class HilbertCurve : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); @@ -236,8 +266,15 @@ public partial class HilbertCurve : IExample float handleX = bounds.X + pct * bounds.Width; DrawRectangle((int)(handleX - 5), (int)bounds.Y, 10, (int)bounds.Height, Color.DarkGray); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (textLeft != null) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (textRight != null) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (textLeft != null) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (textRight != null) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/Kaleidoscope.cs b/Examples/Shapes/Kaleidoscope.cs index 85827ba..351858e 100644 --- a/Examples/Shapes/Kaleidoscope.cs +++ b/Examples/Shapes/Kaleidoscope.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shapes; diff --git a/Examples/Shapes/LinesBezier.cs b/Examples/Shapes/LinesBezier.cs index 0f8daa8..eff31cc 100644 --- a/Examples/Shapes/LinesBezier.cs +++ b/Examples/Shapes/LinesBezier.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class LinesBezier : IExample diff --git a/Examples/Shapes/LinesDrawing.cs b/Examples/Shapes/LinesDrawing.cs index 7e4fd9e..c700bcb 100644 --- a/Examples/Shapes/LinesDrawing.cs +++ b/Examples/Shapes/LinesDrawing.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shapes; @@ -71,7 +69,10 @@ public partial class LinesDrawing : IExample // Update //---------------------------------------------------------------------------------- // Disable the hint text once the user clicks - if (IsMouseButtonPressed(MouseButton.Left) && startText) startText = false; + if (IsMouseButtonPressed(MouseButton.Left) && startText) + { + startText = false; + } // Clear the canvas when the user middle-clicks if (IsMouseButtonPressed(MouseButton.Middle)) @@ -97,12 +98,18 @@ public partial class LinesDrawing : IExample // While the hue is >=360, subtract it to bring it down into the range 0-360 // This is more visually accurate than resetting to zero - while (lineHue >= 360.0f) lineHue -= 360.0f; + while (lineHue >= 360.0f) + { + lineHue -= 360.0f; + } // Create the final color drawColor = ColorFromHSV(lineHue, 1.0f, 1.0f); } - else if (rightButtonDown) drawColor = Color.RayWhite; // Use the background color as an "eraser" + else if (rightButtonDown) + { + drawColor = Color.RayWhite; // Use the background color as an "eraser" + } // Draw the line onto the canvas BeginTextureMode(canvas); @@ -129,10 +136,16 @@ public partial class LinesDrawing : IExample DrawTextureRec(canvas.Texture, new Rectangle(0.0f, 0.0f, (float)canvas.Texture.Width, (float)-canvas.Texture.Height), Vector2Zero(), Color.White); // Draw the preview circle - if (!leftButtonDown) DrawCircleLinesV(GetMousePosition(), lineThickness/2.0f, new Color(127, 127, 127, 127)); + if (!leftButtonDown) + { + DrawCircleLinesV(GetMousePosition(), lineThickness/2.0f, new Color(127, 127, 127, 127)); + } - // Draw the hint text - if (startText) DrawText("try clicking and dragging!", 275, 215, 20, Color.LightGray); + // Draw the hint text + if (startText) + { + DrawText("try clicking and dragging!", 275, 215, 20, Color.LightGray); + } EndDrawing(); //---------------------------------------------------------------------------------- diff --git a/Examples/Shapes/LogoRaylibAnim.cs b/Examples/Shapes/LogoRaylibAnim.cs index 4c2f022..f65a258 100644 --- a/Examples/Shapes/LogoRaylibAnim.cs +++ b/Examples/Shapes/LogoRaylibAnim.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class LogoRaylibAnim : IExample diff --git a/Examples/Shapes/LogoRaylibShape.cs b/Examples/Shapes/LogoRaylibShape.cs index 660f849..db0b1a5 100644 --- a/Examples/Shapes/LogoRaylibShape.cs +++ b/Examples/Shapes/LogoRaylibShape.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class LogoRaylibShape : IExample diff --git a/Examples/Shapes/MathAngleRotation.cs b/Examples/Shapes/MathAngleRotation.cs index 6ea45a0..20c091f 100644 --- a/Examples/Shapes/MathAngleRotation.cs +++ b/Examples/Shapes/MathAngleRotation.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class MathAngleRotation : IExample @@ -59,7 +55,10 @@ public partial class MathAngleRotation : IExample // Update //---------------------------------------------------------------------------------- totalAngle += 1.0f; // degrees per frame - if (totalAngle >= 360.0f) totalAngle -= 360.0f; + if (totalAngle >= 360.0f) + { + totalAngle -= 360.0f; + } //---------------------------------------------------------------------------------- // Draw diff --git a/Examples/Shapes/MathSineCosine.cs b/Examples/Shapes/MathSineCosine.cs index efe2286..5c3733d 100644 --- a/Examples/Shapes/MathSineCosine.cs +++ b/Examples/Shapes/MathSineCosine.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Shapes; @@ -122,14 +119,20 @@ public partial class MathSineCosine : IExample DrawLineDashed(new Vector2(point.X, center.Y), new Vector2(point.X, point.Y), 10, 4, Color.Red); DrawText($"Sine {sinRad:0.00}", 640, 190, 6, Color.Red); DrawCircleV(new Vector2(start.X + (angle / 360.0f) * start.Width, start.Y + ((-sinRad + 1) * start.Height / 2.0f)), 4.0f, Color.Red); - fixed (Vector2* p = sinePoints) DrawSplineLinear(p, WAVE_POINTS, 1.0f, Color.Red); + fixed (Vector2* p = sinePoints) + { + DrawSplineLinear(p, WAVE_POINTS, 1.0f, Color.Red); + } // Cosine (blue - horizontal) DrawLineEx(new Vector2(center.X, center.Y), new Vector2(point.X, center.Y), 2.0f, Color.Blue); DrawLineDashed(new Vector2(center.X, point.Y), new Vector2(point.X, point.Y), 10, 4, Color.Blue); DrawText($"Cosine {cosRad:0.00}", 640, 210, 6, Color.Blue); DrawCircleV(new Vector2(start.X + (angle / 360.0f) * start.Width, start.Y + ((-cosRad + 1) * start.Height / 2.0f)), 4.0f, Color.Blue); - fixed (Vector2* p = cosPoints) DrawSplineLinear(p, WAVE_POINTS, 1.0f, Color.Blue); + fixed (Vector2* p = cosPoints) + { + DrawSplineLinear(p, WAVE_POINTS, 1.0f, Color.Blue); + } // Tangent (purple) DrawLineEx(new Vector2(limitMax.X, center.Y), new Vector2(limitMax.X, tangentPoint.Y), 2.0f, Color.Purple); diff --git a/Examples/Shapes/MouseTrail.cs b/Examples/Shapes/MouseTrail.cs index 82bc57f..7878640 100644 --- a/Examples/Shapes/MouseTrail.cs +++ b/Examples/Shapes/MouseTrail.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class MouseTrail : IExample diff --git a/Examples/Shapes/PenroseTile.cs b/Examples/Shapes/PenroseTile.cs index 3dc630a..ab02a50 100644 --- a/Examples/Shapes/PenroseTile.cs +++ b/Examples/Shapes/PenroseTile.cs @@ -16,11 +16,7 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using System.Collections.Generic; using System.Text; -using static Raylib_cs.Raylib; namespace Examples.Shapes; @@ -79,7 +75,10 @@ public partial class PenroseTile : IExample // Initialize new penrose tile ls = CreatePenroseLSystem(drawLength * (generations / (float)maxGenerations)); - for (int i = 0; i < generations; i++) BuildProductionStep(ls); + for (int i = 0; i < generations; i++) + { + BuildProductionStep(ls); + } } public void Update() @@ -100,14 +99,20 @@ public partial class PenroseTile : IExample if (generations > minGenerations) { generations--; - if (generations > 0) rebuild = true; + if (generations > 0) + { + rebuild = true; + } } } if (rebuild) { ls = CreatePenroseLSystem(drawLength * (generations / (float)maxGenerations)); - for (int i = 0; i < generations; i++) BuildProductionStep(ls); + for (int i = 0; i < generations; i++) + { + BuildProductionStep(ls); + } } //---------------------------------------------------------------------------------- @@ -117,7 +122,10 @@ public partial class PenroseTile : IExample ClearBackground(Color.RayWhite); - if (generations > 0) DrawPenroseLSystem(ls); + if (generations > 0) + { + DrawPenroseLSystem(ls); + } DrawText("penrose l-system", 10, 10, 20, Color.DarkGray); DrawText("press up or down to change generations", 10, 30, 20, Color.DarkGray); @@ -143,8 +151,14 @@ public partial class PenroseTile : IExample // Pop turtle state step private TurtleState PopTurtleState() { - if (turtleStack.Count > 0) return turtleStack.Pop(); - else TraceLog(TraceLogLevel.Warning, "TURTLE STACK UNDERFLOW!"); + if (turtleStack.Count > 0) + { + return turtleStack.Pop(); + } + else + { + TraceLog(TraceLogLevel.Warning, "TURTLE STACK UNDERFLOW!"); + } return new TurtleState(); } @@ -186,8 +200,11 @@ public partial class PenroseTile : IExample case 'Z': newProduction.Append(ls.ruleZ); break; default: { - if (step != 'F') newProduction.Append(step); - } break; + if (step != 'F') + { + newProduction.Append(step); + } + } break; } } @@ -211,7 +228,10 @@ public partial class PenroseTile : IExample int productionLength = production.Length; ls.steps += 12; - if (ls.steps > productionLength) ls.steps = productionLength; + if (ls.steps > productionLength) + { + ls.steps = productionLength; + } for (int i = 0; i < ls.steps; i++) { @@ -234,19 +254,34 @@ public partial class PenroseTile : IExample } else if (step == '+') { - for (int j = 0; j < repeats; j++) turtle.angle += ls.theta; + for (int j = 0; j < repeats; j++) + { + turtle.angle += ls.theta; + } repeats = 1; } else if (step == '-') { - for (int j = 0; j < repeats; j++) turtle.angle += -ls.theta; + for (int j = 0; j < repeats; j++) + { + turtle.angle += -ls.theta; + } repeats = 1; } - else if (step == '[') PushTurtleState(turtle); - else if (step == ']') turtle = PopTurtleState(); - else if ((step >= 48) && (step <= 57)) repeats = (int)step - 48; + else if (step == '[') + { + PushTurtleState(turtle); + } + else if (step == ']') + { + turtle = PopTurtleState(); + } + else if ((step >= 48) && (step <= 57)) + { + repeats = (int)step - 48; + } } turtleStack.Clear(); diff --git a/Examples/Shapes/PieChart.cs b/Examples/Shapes/PieChart.cs index f61adff..65a8397 100644 --- a/Examples/Shapes/PieChart.cs +++ b/Examples/Shapes/PieChart.cs @@ -15,10 +15,7 @@ * ********************************************************************************************/ -using System; -using System.Numerics; using System.Text; -using static Raylib_cs.Raylib; namespace Examples.Shapes; @@ -71,7 +68,10 @@ public partial class PieChart : IExample labels = new StringBuilder[MAX_PIE_SLICES]; editingLabel = new bool[MAX_PIE_SLICES]; - for (int i = 0; i < MAX_PIE_SLICES; i++) labels[i] = new StringBuilder($"Slice {i + 1:D2}"); + for (int i = 0; i < MAX_PIE_SLICES; i++) + { + labels[i] = new StringBuilder($"Slice {i + 1:D2}"); + } showValues = true; showPercentages = false; @@ -110,7 +110,10 @@ public partial class PieChart : IExample //---------------------------------------------------------------------------------- // Calculate total value for percentage calculations totalValue = 0.0f; - for (int i = 0; i < sliceCount; i++) totalValue += values[i]; + for (int i = 0; i < sliceCount; i++) + { + totalValue += values[i]; + } // Check for mouse hover over slices hoveredSlice = -1; // Reset hovered slice @@ -124,7 +127,10 @@ public partial class PieChart : IExample if (distance <= radius) // Inside the pie radius { float angle = MathF.Atan2(dy, dx) * RAD2DEG; - if (angle < 0) angle += 360; + if (angle < 0) + { + angle += 360; + } float currentAngle = 0.0f; for (int i = 0; i < sliceCount; i++) @@ -159,7 +165,10 @@ public partial class PieChart : IExample float currentRadius = radius; // Make the hovered slice pop out by adding pixels to its radius - if (i == hoveredSlice) currentRadius += 20.0f; + if (i == hoveredSlice) + { + currentRadius += 20.0f; + } // Draw the pie slice using raylib's DrawCircleSector function DrawCircleSector(center, currentRadius, startAngle, startAngle + sweepAngle, 120, color); @@ -168,10 +177,22 @@ public partial class PieChart : IExample if (values[i] > 0) { string labelText; - if (showValues && showPercentages) labelText = $"{values[i]:F1} ({(values[i] / totalValue) * 100.0f:F0}%)"; - else if (showValues) labelText = $"{values[i]:F1}"; - else if (showPercentages) labelText = $"{(values[i] / totalValue) * 100.0f:F0}%"; - else labelText = ""; + if (showValues && showPercentages) + { + labelText = $"{values[i]:F1} ({(values[i] / totalValue) * 100.0f:F0}%)"; + } + else if (showValues) + { + labelText = $"{values[i]:F1}"; + } + else if (showPercentages) + { + labelText = $"{(values[i] / totalValue) * 100.0f:F0}%"; + } + else + { + labelText = ""; + } Vector2 textSize = MeasureTextEx(GetFontDefault(), labelText, 20, 1); float labelRadius = radius * 0.7f; @@ -182,7 +203,10 @@ public partial class PieChart : IExample // Draw inner circle to create donut effect // TODO: This is a hacky solution, better use DrawRing() - if (showDonut) DrawCircleV(center, donutInnerRadius, Color.RayWhite); + if (showDonut) + { + DrawCircleV(center, donutInnerRadius, Color.RayWhite); + } startAngle += sweepAngle; } @@ -196,7 +220,11 @@ public partial class PieChart : IExample GuiCheckBox(new Rectangle(panelPos.X + 20, (float)panelPos.Y + 12 + 70, 20, 20), "Show Percentages", ref showPercentages); GuiCheckBox(new Rectangle(panelPos.X + 20, (float)panelPos.Y + 12 + 100, 20, 20), "Make Donut", ref showDonut); - if (showDonut) GuiDisable(); + if (showDonut) + { + GuiDisable(); + } + GuiSliderBar(new Rectangle(panelPos.X + 80, (float)panelPos.Y + 12 + 130, panelRect.Width - 100, 30), "Inner Radius", null, ref donutInnerRadius, 5.0f, radius - 10.0f); GuiEnable(); @@ -217,8 +245,15 @@ public partial class PieChart : IExample { scrollContentOffset.Y += GetMouseWheelMove() * 20.0f; float minOffset = MathF.Min(0.0f, scrollPanelBounds.Height - contentHeight); - if (scrollContentOffset.Y < minOffset) scrollContentOffset.Y = minOffset; - if (scrollContentOffset.Y > 0.0f) scrollContentOffset.Y = 0.0f; + if (scrollContentOffset.Y < minOffset) + { + scrollContentOffset.Y = minOffset; + } + + if (scrollContentOffset.Y > 0.0f) + { + scrollContentOffset.Y = 0.0f; + } } Rectangle view = scrollPanelBounds; @@ -236,7 +271,10 @@ public partial class PieChart : IExample DrawRectangle((int)(contentX + 15), rowY + 5, 20, 20, color); // Label textbox - if (GuiTextBox(new Rectangle(contentX + 45, (float)rowY, 75, 30), labels[i], 32, editingLabel[i])) editingLabel[i] = !editingLabel[i]; + if (GuiTextBox(new Rectangle(contentX + 45, (float)rowY, 75, 30), labels[i], 32, editingLabel[i])) + { + editingLabel[i] = !editingLabel[i]; + } GuiSliderBar(new Rectangle(contentX + 130, (float)rowY, 110, 30), null, null, ref values[i], 0.0f, 1000.0f); } @@ -267,11 +305,21 @@ public partial class PieChart : IExample { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (!guiDisabled && hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (!guiDisabled && hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiSpinner(Rectangle bounds, string text, ref int value, int minValue, int maxValue) @@ -281,8 +329,15 @@ public partial class PieChart : IExample Rectangle right = new Rectangle(bounds.X + bounds.Width - bounds.Height, bounds.Y, bounds.Height, bounds.Height); Rectangle mid = new Rectangle(bounds.X + bounds.Height, bounds.Y, bounds.Width - 2 * bounds.Height, bounds.Height); - if (!guiDisabled && CheckCollisionPointRec(mouse, left) && IsMouseButtonPressed(MouseButton.Left) && value > minValue) value--; - if (!guiDisabled && CheckCollisionPointRec(mouse, right) && IsMouseButtonPressed(MouseButton.Left) && value < maxValue) value++; + if (!guiDisabled && CheckCollisionPointRec(mouse, left) && IsMouseButtonPressed(MouseButton.Left) && value > minValue) + { + value--; + } + + if (!guiDisabled && CheckCollisionPointRec(mouse, right) && IsMouseButtonPressed(MouseButton.Left) && value < maxValue) + { + value++; + } DrawRectangleRec(mid, Color.RayWhite); DrawRectangleLinesEx(mid, 1, Color.Gray); @@ -294,7 +349,10 @@ public partial class PieChart : IExample DrawText("+", (int)(right.X + right.Width / 2 - 3), (int)(right.Y + right.Height / 2 - 5), 10, Color.DarkGray); string vs = value.ToString(); DrawText(vs, (int)(mid.X + mid.Width / 2 - MeasureText(vs, 10) / 2), (int)(mid.Y + mid.Height / 2 - 5), 10, Color.DarkGray); - if (text != null) DrawText(text, (int)bounds.X - MeasureText(text, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (text != null) + { + DrawText(text, (int)bounds.X - MeasureText(text, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiSliderBar(Rectangle bounds, string textLeft, string textRight, ref float value, float minValue, float maxValue) @@ -304,16 +362,30 @@ public partial class PieChart : IExample if (!guiDisabled && hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, guiDisabled ? Color.Gray : Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), guiDisabled ? Color.DarkGray : Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private bool GuiTextBox(Rectangle bounds, StringBuilder text, int maxChars, bool editMode) @@ -335,7 +407,10 @@ public partial class PieChart : 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); @@ -349,7 +424,10 @@ public partial class PieChart : IExample DrawText("_", (int)bounds.X + 4 + MeasureText(content, 10), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); } - if (hover && IsMouseButtonPressed(MouseButton.Left)) pressed = true; + if (hover && IsMouseButtonPressed(MouseButton.Left)) + { + pressed = true; + } return pressed; } diff --git a/Examples/Shapes/RectangleAdvanced.cs b/Examples/Shapes/RectangleAdvanced.cs index 7236ebb..1b2c94b 100644 --- a/Examples/Shapes/RectangleAdvanced.cs +++ b/Examples/Shapes/RectangleAdvanced.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Rlgl; namespace Examples.Shapes; @@ -88,18 +85,35 @@ public partial class RectangleAdvanced : IExample return; } - if (roundnessLeft >= 1.0f) roundnessLeft = 1.0f; - if (roundnessRight >= 1.0f) roundnessRight = 1.0f; + if (roundnessLeft >= 1.0f) + { + roundnessLeft = 1.0f; + } + + if (roundnessRight >= 1.0f) + { + roundnessRight = 1.0f; + } // Calculate corner radius both from right and left float recSize = rec.Width > rec.Height ? rec.Height : rec.Width; float radiusLeft = (recSize * roundnessLeft) / 2; float radiusRight = (recSize * roundnessRight) / 2; - if (radiusLeft <= 0.0f) radiusLeft = 0.0f; - if (radiusRight <= 0.0f) radiusRight = 0.0f; + if (radiusLeft <= 0.0f) + { + radiusLeft = 0.0f; + } - if (radiusRight <= 0.0f && radiusLeft <= 0.0f) return; + if (radiusRight <= 0.0f) + { + radiusRight = 0.0f; + } + + if (radiusRight <= 0.0f && radiusLeft <= 0.0f) + { + return; + } float stepLength = 90.0f / (float)segments; diff --git a/Examples/Shapes/RectangleScaling.cs b/Examples/Shapes/RectangleScaling.cs index 5fbfc84..4a397cf 100644 --- a/Examples/Shapes/RectangleScaling.cs +++ b/Examples/Shapes/RectangleScaling.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class RectangleScaling : IExample diff --git a/Examples/Shapes/RecursiveTree.cs b/Examples/Shapes/RecursiveTree.cs index a522956..a5da13d 100644 --- a/Examples/Shapes/RecursiveTree.cs +++ b/Examples/Shapes/RecursiveTree.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class RecursiveTree : IExample @@ -78,7 +74,10 @@ public partial class RecursiveTree : IExample for (int i = 0; i < count; i++) { Branch branch = branches[i]; - if (branch.length < 2) continue; + if (branch.length < 2) + { + continue; + } float nextLength = branch.length * branchDecay; @@ -108,8 +107,14 @@ public partial class RecursiveTree : IExample Branch branch = branches[i]; if (branch.length >= 2) { - if (bezier) DrawLineBezier(branch.start, branch.end, thick, Color.Red); - else DrawLineEx(branch.start, branch.end, thick, Color.Red); + if (bezier) + { + DrawLineBezier(branch.start, branch.end, thick, Color.Red); + } + else + { + DrawLineEx(branch.start, branch.end, thick, Color.Red); + } } } @@ -146,27 +151,51 @@ public partial class RecursiveTree : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (textLeft != null) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (textRight != null) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (textLeft != null) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (textRight != null) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiCheckBox(Rectangle bounds, string text, ref bool active) { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/RlglColorWheel.cs b/Examples/Shapes/RlglColorWheel.cs index 36c7f41..eaf23a4 100644 --- a/Examples/Shapes/RlglColorWheel.cs +++ b/Examples/Shapes/RlglColorWheel.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; using static Raylib_cs.Rlgl; @@ -146,27 +143,48 @@ public partial class RlglColorWheel : IExample } // Update flag when mouse button is released - if (IsMouseButtonReleased(MouseButton.Left)) settingColor = false; + if (IsMouseButtonReleased(MouseButton.Left)) + { + settingColor = false; + } // Check if the user clicked/released the slider for the color's value - if (sliderHover && IsMouseButtonPressed(MouseButton.Left)) sliderClicked = true; + if (sliderHover && IsMouseButtonPressed(MouseButton.Left)) + { + sliderClicked = true; + } - if (sliderClicked && IsMouseButtonReleased(MouseButton.Left)) sliderClicked = false; + if (sliderClicked && IsMouseButtonReleased(MouseButton.Left)) + { + sliderClicked = false; + } // Update render mode accordingly - if (IsKeyPressed(KeyboardKey.Space)) renderType = DrawMode.Lines; + if (IsKeyPressed(KeyboardKey.Space)) + { + renderType = DrawMode.Lines; + } - if (IsKeyReleased(KeyboardKey.Space)) renderType = DrawMode.Triangles; + if (IsKeyReleased(KeyboardKey.Space)) + { + renderType = DrawMode.Triangles; + } // If the slider or the wheel was clicked, update the current color if (settingColor || sliderClicked) { - if (settingColor) circlePosition = GetMousePosition(); + if (settingColor) + { + circlePosition = GetMousePosition(); + } float distance = Vector2Distance(center, circlePosition) / pointScale; float angle = ((Vector2Angle(new Vector2(0.0f, -pointScale), Vector2Subtract(center, circlePosition)) / MathF.PI + 1.0f) / 2.0f); - if (settingColor && distance > 1.0f) circlePosition = Vector2Add(new Vector2(MathF.Sin(angle * (MathF.PI * 2.0f)) * pointScale, -MathF.Cos(angle * (MathF.PI * 2.0f)) * pointScale), center); + if (settingColor && distance > 1.0f) + { + circlePosition = Vector2Add(new Vector2(MathF.Sin(angle * (MathF.PI * 2.0f)) * pointScale, -MathF.Cos(angle * (MathF.PI * 2.0f)) * pointScale), center); + } float angle360 = angle * 360.0f; float valueActual = Clamp(distance, 0.0f, 1.0f); @@ -288,16 +306,30 @@ public partial class RlglColorWheel : IExample if (hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } public static int Main() diff --git a/Examples/Shapes/RlglTriangle.cs b/Examples/Shapes/RlglTriangle.cs index cb6ee22..77d4009 100644 --- a/Examples/Shapes/RlglTriangle.cs +++ b/Examples/Shapes/RlglTriangle.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Rlgl; namespace Examples.Shapes; @@ -57,7 +55,10 @@ public partial class RlglTriangle : IExample { // Update //---------------------------------------------------------------------------------- - if (IsKeyPressed(KeyboardKey.Space)) linesMode = !linesMode; + if (IsKeyPressed(KeyboardKey.Space)) + { + linesMode = !linesMode; + } // Check selected vertex for (int i = 0; i < 3; i++) @@ -80,11 +81,21 @@ public partial class RlglTriangle : IExample } // Reset index on release - if (IsMouseButtonReleased(MouseButton.Left)) triangleIndex = -1; + if (IsMouseButtonReleased(MouseButton.Left)) + { + triangleIndex = -1; + } // Enable/disable backface culling (2-sided triangles, slower to render) - if (IsKeyPressed(KeyboardKey.Left)) EnableBackfaceCulling(); - if (IsKeyPressed(KeyboardKey.Right)) DisableBackfaceCulling(); + if (IsKeyPressed(KeyboardKey.Left)) + { + EnableBackfaceCulling(); + } + + if (IsKeyPressed(KeyboardKey.Right)) + { + DisableBackfaceCulling(); + } // Reset triangle vertices to starting positions and reset backface culling if (IsKeyPressed(KeyboardKey.R)) @@ -147,10 +158,15 @@ public partial class RlglTriangle : IExample { // Draw handle fill focused by mouse if (CheckCollisionPointCircle(GetMousePosition(), trianglePositions[i], handleRadius)) + { DrawCircleV(trianglePositions[i], handleRadius, ColorAlpha(Color.DarkGray, 0.5f)); + } // Draw handle fill selected - if (i == triangleIndex) DrawCircleV(trianglePositions[i], handleRadius, Color.DarkGray); + if (i == triangleIndex) + { + DrawCircleV(trianglePositions[i], handleRadius, Color.DarkGray); + } // Draw handle outline DrawCircleLinesV(trianglePositions[i], handleRadius, Color.Black); diff --git a/Examples/Shapes/SimpleParticles.cs b/Examples/Shapes/SimpleParticles.cs index 34d0eb6..2ae1b4e 100644 --- a/Examples/Shapes/SimpleParticles.cs +++ b/Examples/Shapes/SimpleParticles.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class SimpleParticles : IExample @@ -90,11 +86,17 @@ public partial class SimpleParticles : IExample // Emit new particles: when emissionRate is 1, emit every frame if (emissionRate < 0) { - if (random.Next(-emissionRate) == 0) EmitParticle(emitterPosition, currentType); + if (random.Next(-emissionRate) == 0) + { + EmitParticle(emitterPosition, currentType); + } } else { - for (int i = 0; i <= emissionRate; i++) EmitParticle(emitterPosition, currentType); + for (int i = 0; i <= emissionRate; i++) + { + EmitParticle(emitterPosition, currentType); + } } // Update the parameters of each particle @@ -104,14 +106,31 @@ public partial class SimpleParticles : IExample UpdateCircularBuffer(); // Change Particle Emission Rate (UP/DOWN arrows) - if (IsKeyPressed(KeyboardKey.Up)) emissionRate++; - if (IsKeyPressed(KeyboardKey.Down)) emissionRate--; + if (IsKeyPressed(KeyboardKey.Up)) + { + emissionRate++; + } + + if (IsKeyPressed(KeyboardKey.Down)) + { + emissionRate--; + } // Change Particle Type (LEFT/RIGHT arrows) - if (IsKeyPressed(KeyboardKey.Right)) currentType = (currentType == ParticleType.Fire) ? ParticleType.Water : (ParticleType)((int)currentType + 1); - if (IsKeyPressed(KeyboardKey.Left)) currentType = (currentType == ParticleType.Water) ? ParticleType.Fire : (ParticleType)((int)currentType - 1); + if (IsKeyPressed(KeyboardKey.Right)) + { + currentType = (currentType == ParticleType.Fire) ? ParticleType.Water : (ParticleType)((int)currentType + 1); + } - if (IsMouseButtonDown(MouseButton.Left)) emitterPosition = GetMousePosition(); + if (IsKeyPressed(KeyboardKey.Left)) + { + currentType = (currentType == ParticleType.Water) ? ParticleType.Fire : (ParticleType)((int)currentType - 1); + } + + if (IsMouseButtonDown(MouseButton.Left)) + { + emitterPosition = GetMousePosition(); + } //---------------------------------------------------------------------------------- // Draw @@ -131,8 +150,14 @@ public partial class SimpleParticles : IExample DrawText("UP/DOWN: Change Particle Emission Rate", 15, 35, 10, Color.Black); DrawText("LEFT/RIGHT: Change Particle Type (Water, Smoke, Fire)", 15, 55, 10, Color.Black); - if (emissionRate < 0) DrawText($"Particles every {-emissionRate} frames | Type: {particleTypeNames[(int)currentType]}", 15, 95, 10, Color.DarkGray); - else DrawText($"{emissionRate + 1} Particles per frame | Type: {particleTypeNames[(int)currentType]}", 15, 95, 10, Color.DarkGray); + if (emissionRate < 0) + { + DrawText($"Particles every {-emissionRate} frames | Type: {particleTypeNames[(int)currentType]}", 15, 95, 10, Color.DarkGray); + } + else + { + DrawText($"{emissionRate + 1} Particles per frame | Type: {particleTypeNames[(int)currentType]}", 15, 95, 10, Color.DarkGray); + } DrawFPS(screenWidth - 80, 10); @@ -227,8 +252,11 @@ public partial class SimpleParticles : IExample buffer[i].color.A -= 4; // Decrement alpha: smoke fades // If alpha transparent, particle dies - if (buffer[i].color.A < 4) buffer[i].alive = false; - } break; + if (buffer[i].color.A < 4) + { + buffer[i].alive = false; + } + } break; case ParticleType.Fire: { // Add a little horizontal oscillation to fire particles @@ -239,8 +267,11 @@ public partial class SimpleParticles : IExample buffer[i].color.G -= 3; // Decrement green: fire turns reddish starting from yellow // If radius too small, particle dies - if (buffer[i].radius <= 0.02f) buffer[i].alive = false; - } break; + if (buffer[i].radius <= 0.02f) + { + buffer[i].alive = false; + } + } break; default: break; } diff --git a/Examples/Shapes/SplinesDrawing.cs b/Examples/Shapes/SplinesDrawing.cs index b8598d4..ed09257 100644 --- a/Examples/Shapes/SplinesDrawing.cs +++ b/Examples/Shapes/SplinesDrawing.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class SplinesDrawing : IExample @@ -131,14 +128,20 @@ public partial class SplinesDrawing : IExample break; } } - if (IsMouseButtonPressed(MouseButton.Left)) selectedPoint = focusedPoint; + if (IsMouseButtonPressed(MouseButton.Left)) + { + selectedPoint = focusedPoint; + } } // Spline point movement logic if (selectedPoint >= 0) { points[selectedPoint] = GetMousePosition(); - if (IsMouseButtonReleased(MouseButton.Left)) selectedPoint = -1; + if (IsMouseButtonReleased(MouseButton.Left)) + { + selectedPoint = -1; + } } // Cubic Bezier spline control points logic @@ -173,20 +176,45 @@ public partial class SplinesDrawing : IExample // Spline control point movement logic if (selectedControlIndex != -1) { - if (selectedControlStart) control[selectedControlIndex].start = GetMousePosition(); - else control[selectedControlIndex].end = GetMousePosition(); - if (IsMouseButtonReleased(MouseButton.Left)) selectedControlIndex = -1; + if (selectedControlStart) + { + control[selectedControlIndex].start = GetMousePosition(); + } + else + { + control[selectedControlIndex].end = GetMousePosition(); + } + + if (IsMouseButtonReleased(MouseButton.Left)) + { + selectedControlIndex = -1; + } } } // Spline selection logic - if (IsKeyPressed(KeyboardKey.One)) splineTypeActive = 0; - else if (IsKeyPressed(KeyboardKey.Two)) splineTypeActive = 1; - else if (IsKeyPressed(KeyboardKey.Three)) splineTypeActive = 2; - else if (IsKeyPressed(KeyboardKey.Four)) splineTypeActive = 3; + if (IsKeyPressed(KeyboardKey.One)) + { + splineTypeActive = 0; + } + else if (IsKeyPressed(KeyboardKey.Two)) + { + splineTypeActive = 1; + } + else if (IsKeyPressed(KeyboardKey.Three)) + { + splineTypeActive = 2; + } + else if (IsKeyPressed(KeyboardKey.Four)) + { + splineTypeActive = 3; + } // Clear selection when changing to a spline without control points - if (IsKeyPressed(KeyboardKey.One) || IsKeyPressed(KeyboardKey.Two) || IsKeyPressed(KeyboardKey.Three)) selectedControlIndex = -1; + if (IsKeyPressed(KeyboardKey.One) || IsKeyPressed(KeyboardKey.Two) || IsKeyPressed(KeyboardKey.Three)) + { + selectedControlIndex = -1; + } //---------------------------------------------------------------------------------- // Draw @@ -232,8 +260,15 @@ public partial class SplinesDrawing : IExample // Every cubic bezier point have two control points DrawCircleV(control[i].start, 6, Color.Gold); DrawCircleV(control[i].end, 6, Color.Gold); - if (focusedControlIndex == i && focusedControlStart) DrawCircleV(control[i].start, 8, Color.Green); - else if (focusedControlIndex == i && !focusedControlStart) DrawCircleV(control[i].end, 8, Color.Green); + if (focusedControlIndex == i && focusedControlStart) + { + DrawCircleV(control[i].start, 8, Color.Green); + } + else if (focusedControlIndex == i && !focusedControlStart) + { + DrawCircleV(control[i].end, 8, Color.Green); + } + DrawLineEx(points[i], control[i].start, 1.0f, Color.LightGray); DrawLineEx(points[i + 1], control[i].end, 1.0f, Color.LightGray); @@ -251,14 +286,20 @@ public partial class SplinesDrawing : IExample DrawCircleLinesV(points[i], (focusedPoint == i) ? 12.0f : 8.0f, (focusedPoint == i) ? Color.Blue : Color.DarkBlue); if ((splineTypeActive != SPLINE_LINEAR) && (splineTypeActive != SPLINE_BEZIER) && - (i < pointCount - 1)) DrawLineV(points[i], points[i + 1], Color.Gray); + (i < pointCount - 1)) + { + DrawLineV(points[i], points[i + 1], Color.Gray); + } DrawText($"[{points[i].X:F0}, {points[i].Y:F0}]", (int)points[i].X, (int)points[i].Y + 10, 10, Color.Black); } } // Check all possible UI states that require controls lock - if (splineTypeEditMode || (selectedPoint != -1) || (selectedControlIndex != -1)) GuiLock(); + if (splineTypeEditMode || (selectedPoint != -1) || (selectedControlIndex != -1)) + { + GuiLock(); + } // Draw spline config GuiLabel(new Rectangle(12, 62, 140, 24), $"Spline thickness: {(int)splineThickness}"); @@ -266,10 +307,16 @@ public partial class SplinesDrawing : IExample GuiCheckBox(new Rectangle(12, 110, 20, 20), "Show point helpers", ref splineHelpersActive); - if (splineTypeEditMode) GuiUnlock(); + if (splineTypeEditMode) + { + GuiUnlock(); + } GuiLabel(new Rectangle(12, 10, 140, 24), "Spline type:"); - if (GuiDropdownBox(new Rectangle(12, 8 + 24, 140, 28), "LINEAR;BSPLINE;CATMULLROM;BEZIER", ref splineTypeActive, splineTypeEditMode)) splineTypeEditMode = !splineTypeEditMode; + if (GuiDropdownBox(new Rectangle(12, 8 + 24, 140, 28), "LINEAR;BSPLINE;CATMULLROM;BEZIER", ref splineTypeActive, splineTypeEditMode)) + { + splineTypeEditMode = !splineTypeEditMode; + } GuiUnlock(); @@ -299,27 +346,51 @@ public partial class SplinesDrawing : IExample if (!guiLocked && hover && IsMouseButtonDown(MouseButton.Left)) { value = minValue + ((mouse.X - bounds.X) / bounds.Width) * (maxValue - minValue); - if (value < minValue) value = minValue; - if (value > maxValue) value = maxValue; + if (value < minValue) + { + value = minValue; + } + + if (value > maxValue) + { + value = maxValue; + } } DrawRectangleRec(bounds, Color.LightGray); float pct = (value - minValue) / (maxValue - minValue); DrawRectangleRec(new Rectangle(bounds.X, bounds.Y, bounds.Width * pct, bounds.Height), Color.SkyBlue); DrawRectangleLinesEx(bounds, 1, Color.Gray); - if (!string.IsNullOrEmpty(textLeft)) DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); - if (!string.IsNullOrEmpty(textRight)) DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (!string.IsNullOrEmpty(textLeft)) + { + DrawText(textLeft, (int)bounds.X - MeasureText(textLeft, 10) - 5, (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } + + if (!string.IsNullOrEmpty(textRight)) + { + DrawText(textRight, (int)(bounds.X + bounds.Width + 5), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static void GuiCheckBox(Rectangle bounds, string text, ref bool active) { Vector2 mouse = GetMousePosition(); bool hover = CheckCollisionPointRec(mouse, bounds); - if (!guiLocked && hover && IsMouseButtonPressed(MouseButton.Left)) active = !active; + if (!guiLocked && hover && IsMouseButtonPressed(MouseButton.Left)) + { + active = !active; + } DrawRectangleLinesEx(bounds, 1, hover ? Color.DarkBlue : Color.Gray); - if (active) DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); - if (text != null) DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + if (active) + { + DrawRectangle((int)bounds.X + 4, (int)bounds.Y + 4, (int)bounds.Width - 8, (int)bounds.Height - 8, Color.DarkGray); + } + + if (text != null) + { + DrawText(text, (int)(bounds.X + bounds.Width + 8), (int)(bounds.Y + bounds.Height / 2 - 5), 10, Color.DarkGray); + } } private static bool GuiDropdownBox(Rectangle bounds, string text, ref int active, bool editMode) @@ -351,7 +422,10 @@ public partial class SplinesDrawing : IExample } } - if (clickable && hoverMain && IsMouseButtonPressed(MouseButton.Left)) pressed = true; + if (clickable && hoverMain && IsMouseButtonPressed(MouseButton.Left)) + { + pressed = true; + } return pressed; } diff --git a/Examples/Shapes/StarfieldEffect.cs b/Examples/Shapes/StarfieldEffect.cs index bcd64ea..15aa351 100644 --- a/Examples/Shapes/StarfieldEffect.cs +++ b/Examples/Shapes/StarfieldEffect.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; // Required for: Lerp() namespace Examples.Shapes; @@ -71,12 +69,25 @@ public partial class StarfieldEffect : IExample //---------------------------------------------------------------------------------- // Change speed based on mouse float mouseMove = GetMouseWheelMove(); - if ((int)mouseMove != 0) speed += 2.0f * mouseMove / 9.0f; - if (speed < 0.0f) speed = 0.1f; - else if (speed > 2.0f) speed = 2.0f; + if ((int)mouseMove != 0) + { + speed += 2.0f * mouseMove / 9.0f; + } + + if (speed < 0.0f) + { + speed = 0.1f; + } + else if (speed > 2.0f) + { + speed = 2.0f; + } // Toggle lines / points with space bar - if (IsKeyPressed(KeyboardKey.Space)) drawLines = !drawLines; + if (IsKeyPressed(KeyboardKey.Space)) + { + drawLines = !drawLines; + } float dt = GetFrameTime(); for (int i = 0; i < STAR_COUNT; i++) diff --git a/Examples/Shapes/TopDownLights.cs b/Examples/Shapes/TopDownLights.cs index 83e1f6a..6b91205 100644 --- a/Examples/Shapes/TopDownLights.cs +++ b/Examples/Shapes/TopDownLights.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; using static Raylib_cs.Rlgl; @@ -66,7 +64,10 @@ public partial class TopDownLights : IExample public LightInfo() { - for (int i = 0; i < MAX_SHADOWS; i++) shadows[i] = new ShadowGeometry(); + for (int i = 0; i < MAX_SHADOWS; i++) + { + shadows[i] = new ShadowGeometry(); + } } } @@ -85,7 +86,10 @@ public partial class TopDownLights : IExample public void Init() { lights = new LightInfo[MAX_LIGHTS]; - for (int i = 0; i < MAX_LIGHTS; i++) lights[i] = new LightInfo(); + for (int i = 0; i < MAX_LIGHTS; i++) + { + lights[i] = new LightInfo(); + } // Initialize our 'world' of boxes boxCount = 0; @@ -112,7 +116,10 @@ public partial class TopDownLights : IExample // Update //---------------------------------------------------------------------------------- // Drag light 0 - if (IsMouseButtonDown(MouseButton.Left)) MoveLight(0, GetMousePosition().X, GetMousePosition().Y); + if (IsMouseButtonDown(MouseButton.Left)) + { + MoveLight(0, GetMousePosition().X, GetMousePosition().Y); + } // Make a new light if (IsMouseButtonPressed(MouseButton.Right) && (nextLight < MAX_LIGHTS)) @@ -122,13 +129,19 @@ public partial class TopDownLights : IExample } // Toggle debug info - if (IsKeyPressed(KeyboardKey.F1)) showLines = !showLines; + if (IsKeyPressed(KeyboardKey.F1)) + { + showLines = !showLines; + } // Update the lights and keep track if any were dirty so we know if we need to update the master light mask bool dirtyLights = false; for (int i = 0; i < MAX_LIGHTS; i++) { - if (UpdateLight(i, boxes, boxCount)) dirtyLights = true; + if (UpdateLight(i, boxes, boxCount)) + { + dirtyLights = true; + } } // Update the light mask @@ -146,7 +159,10 @@ public partial class TopDownLights : IExample // Merge in all the light masks for (int i = 0; i < MAX_LIGHTS; i++) { - if (lights[i].active) DrawTextureRec(lights[i].mask.Texture, new Rectangle(0, 0, (float)GetScreenWidth(), -(float)GetScreenHeight()), Vector2Zero(), Color.White); + if (lights[i].active) + { + DrawTextureRec(lights[i].mask.Texture, new Rectangle(0, 0, (float)GetScreenWidth(), -(float)GetScreenHeight()), Vector2Zero(), Color.White); + } } DrawRenderBatchActive(); @@ -172,7 +188,10 @@ public partial class TopDownLights : IExample // Draw the lights for (int i = 0; i < MAX_LIGHTS; i++) { - if (lights[i].active) DrawCircle((int)lights[i].position.X, (int)lights[i].position.Y, 10, (i == 0) ? Color.Yellow : Color.White); + if (lights[i].active) + { + DrawCircle((int)lights[i].position.X, (int)lights[i].position.Y, 10, (i == 0) ? Color.Yellow : Color.White); + } } if (showLines) @@ -184,7 +203,10 @@ public partial class TopDownLights : IExample for (int b = 0; b < boxCount; b++) { - if (CheckCollisionRecs(boxes[b], lights[0].bounds)) DrawRectangleRec(boxes[b], Color.Purple); + if (CheckCollisionRecs(boxes[b], lights[0].bounds)) + { + DrawRectangleRec(boxes[b], Color.Purple); + } DrawRectangleLines((int)boxes[b].X, (int)boxes[b].Y, (int)boxes[b].Width, (int)boxes[b].Height, Color.DarkBlue); } @@ -210,7 +232,10 @@ public partial class TopDownLights : IExample UnloadRenderTexture(lightMask); for (int i = 0; i < MAX_LIGHTS; i++) { - if (lights[i].active) UnloadRenderTexture(lights[i].mask); + if (lights[i].active) + { + UnloadRenderTexture(lights[i].mask); + } } } @@ -233,7 +258,10 @@ public partial class TopDownLights : IExample // It takes the edge and projects it back by the light radius and turns it into a quad private void ComputeShadowVolumeForEdge(int slot, Vector2 sp, Vector2 ep) { - if (lights[slot].shadowCount >= MAX_SHADOWS) return; + if (lights[slot].shadowCount >= MAX_SHADOWS) + { + return; + } float extension = lights[slot].outerRadius * 2; @@ -271,7 +299,10 @@ public partial class TopDownLights : IExample // See if a light needs to update it's mask private bool UpdateLight(int slot, Rectangle[] boxes, int count) { - if (!lights[slot].active || !lights[slot].dirty) return false; + if (!lights[slot].active || !lights[slot].dirty) + { + return false; + } lights[slot].dirty = false; lights[slot].shadowCount = 0; @@ -280,10 +311,16 @@ public partial class TopDownLights : IExample for (int i = 0; i < count; i++) { // Are we in a box? if so we are not valid - if (CheckCollisionPointRec(lights[slot].position, boxes[i])) return false; + if (CheckCollisionPointRec(lights[slot].position, boxes[i])) + { + return false; + } // If this box is outside our bounds, we can skip it - if (!CheckCollisionRecs(lights[slot].bounds, boxes[i])) continue; + if (!CheckCollisionRecs(lights[slot].bounds, boxes[i])) + { + continue; + } // Check the edges that are on the same side we are, and cast shadow volumes out from them @@ -291,22 +328,34 @@ public partial class TopDownLights : IExample Vector2 sp = new Vector2(boxes[i].X, boxes[i].Y); Vector2 ep = new Vector2(boxes[i].X + boxes[i].Width, boxes[i].Y); - if (lights[slot].position.Y > ep.Y) ComputeShadowVolumeForEdge(slot, sp, ep); + if (lights[slot].position.Y > ep.Y) + { + ComputeShadowVolumeForEdge(slot, sp, ep); + } // Right sp = ep; ep.Y += boxes[i].Height; - if (lights[slot].position.X < ep.X) ComputeShadowVolumeForEdge(slot, sp, ep); + if (lights[slot].position.X < ep.X) + { + ComputeShadowVolumeForEdge(slot, sp, ep); + } // Bottom sp = ep; ep.X -= boxes[i].Width; - if (lights[slot].position.Y < ep.Y) ComputeShadowVolumeForEdge(slot, sp, ep); + if (lights[slot].position.Y < ep.Y) + { + ComputeShadowVolumeForEdge(slot, sp, ep); + } // Left sp = ep; ep.Y -= boxes[i].Height; - if (lights[slot].position.X > ep.X) ComputeShadowVolumeForEdge(slot, sp, ep); + if (lights[slot].position.X > ep.X) + { + ComputeShadowVolumeForEdge(slot, sp, ep); + } // The box itself lights[slot].shadows[lights[slot].shadowCount].vertices[0] = new Vector2(boxes[i].X, boxes[i].Y); @@ -336,7 +385,10 @@ public partial class TopDownLights : IExample SetBlendMode(BlendMode.Custom); // If we are valid, then draw the light radius to the alpha mask - if (lights[slot].valid) DrawCircleGradient(lights[slot].position, lights[slot].outerRadius, ColorAlpha(Color.White, 0), Color.White); + if (lights[slot].valid) + { + DrawCircleGradient(lights[slot].position, lights[slot].outerRadius, ColorAlpha(Color.White, 0), Color.White); + } DrawRenderBatchActive(); diff --git a/Examples/Shapes/TriangleStrip.cs b/Examples/Shapes/TriangleStrip.cs index fc1ad44..3b851ec 100644 --- a/Examples/Shapes/TriangleStrip.cs +++ b/Examples/Shapes/TriangleStrip.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shapes; public partial class TriangleStrip : IExample diff --git a/Examples/Shapes/VectorAngle.cs b/Examples/Shapes/VectorAngle.cs index 7cb07ea..d3fa631 100644 --- a/Examples/Shapes/VectorAngle.cs +++ b/Examples/Shapes/VectorAngle.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; // Required for: Vector2LineAngle() namespace Examples.Shapes; @@ -51,14 +49,27 @@ public partial class VectorAngle : IExample //---------------------------------------------------------------------------------- float startangle = 0.0f; - if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1) * RAD2DEG; - if (angleMode == 1) startangle = 0.0f; + if (angleMode == 0) + { + startangle = -Vector2LineAngle(v0, v1) * RAD2DEG; + } + + if (angleMode == 1) + { + startangle = 0.0f; + } v2 = GetMousePosition(); - if (IsKeyPressed(KeyboardKey.Space)) angleMode = (angleMode == 0) ? 1 : 0; + if (IsKeyPressed(KeyboardKey.Space)) + { + angleMode = (angleMode == 0) ? 1 : 0; + } - if ((angleMode == 0) && IsMouseButtonDown(MouseButton.Right)) v1 = GetMousePosition(); + if ((angleMode == 0) && IsMouseButtonDown(MouseButton.Right)) + { + v1 = GetMousePosition(); + } if (angleMode == 0) { @@ -104,11 +115,21 @@ public partial class VectorAngle : IExample DrawText("v0", (int)v0.X, (int)v0.Y, 10, Color.DarkGray); // If the line from v0 to v1 would overlap the text, move it's position up 10 - if (angleMode == 0 && Vector2Subtract(v0, v1).Y > 0.0f) DrawText("v1", (int)v1.X, (int)v1.Y - 10, 10, Color.DarkGray); - if (angleMode == 0 && Vector2Subtract(v0, v1).Y < 0.0f) DrawText("v1", (int)v1.X, (int)v1.Y, 10, Color.DarkGray); + if (angleMode == 0 && Vector2Subtract(v0, v1).Y > 0.0f) + { + DrawText("v1", (int)v1.X, (int)v1.Y - 10, 10, Color.DarkGray); + } + + if (angleMode == 0 && Vector2Subtract(v0, v1).Y < 0.0f) + { + DrawText("v1", (int)v1.X, (int)v1.Y, 10, Color.DarkGray); + } // If angle mode 1, use v1 to emphasize the horizontal line - if (angleMode == 1) DrawText("v1", (int)v0.X + 40, (int)v0.Y, 10, Color.DarkGray); + if (angleMode == 1) + { + DrawText("v1", (int)v0.X + 40, (int)v0.Y, 10, Color.DarkGray); + } // position adjusted by -10 so it isn't hidden by cursor DrawText("v2", (int)v2.X - 10, (int)v2.Y - 10, 10, Color.DarkGray); diff --git a/Examples/Shared/Easings.cs b/Examples/Shared/Easings.cs index 4652f41..ccf7bae 100644 --- a/Examples/Shared/Easings.cs +++ b/Examples/Shared/Easings.cs @@ -1,5 +1,3 @@ -using System; - namespace Examples.Shared; public static class Easings diff --git a/Examples/Shared/PbrLights.cs b/Examples/Shared/PbrLights.cs index 1b64576..74a6c02 100644 --- a/Examples/Shared/PbrLights.cs +++ b/Examples/Shared/PbrLights.cs @@ -1,6 +1,3 @@ -using static Raylib_cs.Raylib; -using System.Numerics; - namespace Examples.Shared; public struct PbrLight diff --git a/Examples/Shared/Rlights.cs b/Examples/Shared/Rlights.cs index 21ba825..bef5872 100644 --- a/Examples/Shared/Rlights.cs +++ b/Examples/Shared/Rlights.cs @@ -1,6 +1,3 @@ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Shared; public struct Light diff --git a/Examples/Text/CodepointsLoading.cs b/Examples/Text/CodepointsLoading.cs index 1846dd1..77e5d3f 100644 --- a/Examples/Text/CodepointsLoading.cs +++ b/Examples/Text/CodepointsLoading.cs @@ -13,11 +13,7 @@ * ********************************************************************************************/ -using System.Numerics; -using System.Linq; using System.Globalization; -using System.Collections.Generic; -using static Raylib_cs.Raylib; namespace Examples.Text; diff --git a/Examples/Text/FontFilters.cs b/Examples/Text/FontFilters.cs index e7e5260..c0b6129 100644 --- a/Examples/Text/FontFilters.cs +++ b/Examples/Text/FontFilters.cs @@ -17,9 +17,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class FontFilters : IExample diff --git a/Examples/Text/FontLoading.cs b/Examples/Text/FontLoading.cs index 15d842a..7cdf3df 100644 --- a/Examples/Text/FontLoading.cs +++ b/Examples/Text/FontLoading.cs @@ -22,9 +22,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class FontLoading : IExample diff --git a/Examples/Text/FontSdf.cs b/Examples/Text/FontSdf.cs index c323ccf..96df616 100644 --- a/Examples/Text/FontSdf.cs +++ b/Examples/Text/FontSdf.cs @@ -13,11 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using System.Runtime.InteropServices; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class FontSdf : IExample diff --git a/Examples/Text/FontSpritefont.cs b/Examples/Text/FontSpritefont.cs index 91c30d6..bf5fdea 100644 --- a/Examples/Text/FontSpritefont.cs +++ b/Examples/Text/FontSpritefont.cs @@ -23,9 +23,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class FontSpritefont : IExample diff --git a/Examples/Text/FormatText.cs b/Examples/Text/FormatText.cs index 592b377..ddd8c85 100644 --- a/Examples/Text/FormatText.cs +++ b/Examples/Text/FormatText.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class FormatText : IExample diff --git a/Examples/Text/InlineStyling.cs b/Examples/Text/InlineStyling.cs index c61a696..0820d88 100644 --- a/Examples/Text/InlineStyling.cs +++ b/Examples/Text/InlineStyling.cs @@ -15,11 +15,7 @@ * ********************************************************************************************/ -using System; -using System.Numerics; using System.Text; -using Raylib_cs; -using static Raylib_cs.Raylib; namespace Examples.Text; @@ -170,7 +166,10 @@ public partial class InlineStyling : IExample colHexText.Append(ch); colHexCount++; } - else break; // Only affects while loop + else + { + break; // Only affects while loop + } } // Convert hex color text into actual Color @@ -192,11 +191,20 @@ public partial class InlineStyling : IExample int index = GetGlyphIndex(font, codepoint); float increaseX = 0.0f; - if (font.Glyphs[index].AdvanceX == 0) increaseX = (font.Recs[index].Width * scaleFactor + spacing); - else increaseX += (font.Glyphs[index].AdvanceX * scaleFactor + spacing); + if (font.Glyphs[index].AdvanceX == 0) + { + increaseX = (font.Recs[index].Width * scaleFactor + spacing); + } + else + { + increaseX += (font.Glyphs[index].AdvanceX * scaleFactor + spacing); + } // Draw background rectangle color (if required) - if (colBack.A > 0) DrawRectangleRec(new Rectangle(position.X + textOffsetX, position.Y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding), colBack); + if (colBack.A > 0) + { + DrawRectangleRec(new Rectangle(position.X + textOffsetX, position.Y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding), colBack); + } if ((codepoint != ' ') && (codepoint != '\t')) { @@ -217,7 +225,10 @@ public partial class InlineStyling : IExample { Vector2 textSize = new(0, 0); - if ((font.Texture.Id == 0) || (text == null) || (text.Length == 0)) return textSize; // Security check + if ((font.Texture.Id == 0) || (text == null) || (text.Length == 0)) + { + return textSize; // Security check + } using var textNative = new Utf8Buffer(text); sbyte* t = textNative.AsPointer(); @@ -257,7 +268,10 @@ public partial class InlineStyling : IExample { colHexCount++; } - else break; // Only affects while loop + else + { + break; // Only affects while loop + } } i += (colHexCount + 1); // Skip color value retrieved and ']' @@ -268,8 +282,14 @@ public partial class InlineStyling : IExample { index = GetGlyphIndex(font, codepoint); - if (font.Glyphs[index].AdvanceX > 0) textWidth += font.Glyphs[index].AdvanceX; - else textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX); + if (font.Glyphs[index].AdvanceX > 0) + { + textWidth += font.Glyphs[index].AdvanceX; + } + else + { + textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX); + } validCodepointCounter++; i += codepointByteCount; diff --git a/Examples/Text/InputBox.cs b/Examples/Text/InputBox.cs index 6356b5d..4b81145 100644 --- a/Examples/Text/InputBox.cs +++ b/Examples/Text/InputBox.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class InputBox : IExample diff --git a/Examples/Text/RaylibFonts.cs b/Examples/Text/RaylibFonts.cs index ba1da0a..b9cff65 100644 --- a/Examples/Text/RaylibFonts.cs +++ b/Examples/Text/RaylibFonts.cs @@ -16,9 +16,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class RaylibFonts : IExample diff --git a/Examples/Text/RectangleBounds.cs b/Examples/Text/RectangleBounds.cs index 3030298..8a10a81 100644 --- a/Examples/Text/RectangleBounds.cs +++ b/Examples/Text/RectangleBounds.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class RectangleBounds : IExample diff --git a/Examples/Text/StringsManagement.cs b/Examples/Text/StringsManagement.cs index 79ec512..3213405 100644 --- a/Examples/Text/StringsManagement.cs +++ b/Examples/Text/StringsManagement.cs @@ -15,12 +15,7 @@ * ********************************************************************************************/ -using System; -using System.Collections.Generic; -using System.Numerics; using System.Text; -using Raylib_cs; -using static Raylib_cs.Raylib; namespace Examples.Text; @@ -135,12 +130,35 @@ public partial class StringsManagement : IExample } // Reset using TextTo* functions - if (IsKeyPressed(KeyboardKey.One)) PrepareFirstTextParticle("raylib => fun videogames programming!"); - if (IsKeyPressed(KeyboardKey.Two)) PrepareFirstTextParticle(TextToUpper("raylib => fun videogames programming!")); - if (IsKeyPressed(KeyboardKey.Three)) PrepareFirstTextParticle(TextToLower("raylib => fun videogames programming!")); - if (IsKeyPressed(KeyboardKey.Four)) PrepareFirstTextParticle(TextToPascal("raylib_fun_videogames_programming")); - if (IsKeyPressed(KeyboardKey.Five)) PrepareFirstTextParticle(TextToSnake("RaylibFunVideogamesProgramming")); - if (IsKeyPressed(KeyboardKey.Six)) PrepareFirstTextParticle(TextToCamel("raylib_fun_videogames_programming")); + if (IsKeyPressed(KeyboardKey.One)) + { + PrepareFirstTextParticle("raylib => fun videogames programming!"); + } + + if (IsKeyPressed(KeyboardKey.Two)) + { + PrepareFirstTextParticle(TextToUpper("raylib => fun videogames programming!")); + } + + if (IsKeyPressed(KeyboardKey.Three)) + { + PrepareFirstTextParticle(TextToLower("raylib => fun videogames programming!")); + } + + if (IsKeyPressed(KeyboardKey.Four)) + { + PrepareFirstTextParticle(TextToPascal("raylib_fun_videogames_programming")); + } + + if (IsKeyPressed(KeyboardKey.Five)) + { + PrepareFirstTextParticle(TextToSnake("RaylibFunVideogamesProgramming")); + } + + if (IsKeyPressed(KeyboardKey.Six)) + { + PrepareFirstTextParticle(TextToCamel("raylib_fun_videogames_programming")); + } // Slice by char pressed only when we have one text particle int charPressed = GetCharPressed(); diff --git a/Examples/Text/Text3D.cs b/Examples/Text/Text3D.cs index 8340300..f734a9a 100644 --- a/Examples/Text/Text3D.cs +++ b/Examples/Text/Text3D.cs @@ -28,11 +28,7 @@ * ********************************************************************************************/ -using System; -using System.Numerics; using System.Text; -using Raylib_cs; -using static Raylib_cs.Raylib; namespace Examples.Text; @@ -182,8 +178,16 @@ public partial class Text3D : IExample } // Handle Events - if (IsKeyPressed(KeyboardKey.F1)) showLetterBoundry = !showLetterBoundry; - if (IsKeyPressed(KeyboardKey.F2)) showTextBoundry = !showTextBoundry; + if (IsKeyPressed(KeyboardKey.F1)) + { + showLetterBoundry = !showLetterBoundry; + } + + if (IsKeyPressed(KeyboardKey.F2)) + { + showTextBoundry = !showTextBoundry; + } + if (IsKeyPressed(KeyboardKey.F3)) { // Handle camera change @@ -226,18 +230,50 @@ public partial class Text3D : IExample } // Handle text layers changes - if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1) --layers; } - else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers) ++layers; } + if (IsKeyPressed(KeyboardKey.Home)) { if (layers > 1) + { + --layers; + } + } + else if (IsKeyPressed(KeyboardKey.End)) { if (layers < TextMaxLayers) + { + ++layers; + } + } // Handle text changes - if (IsKeyPressed(KeyboardKey.Left)) fontSize -= 0.5f; - else if (IsKeyPressed(KeyboardKey.Right)) fontSize += 0.5f; - else if (IsKeyPressed(KeyboardKey.Up)) fontSpacing -= 0.1f; - else if (IsKeyPressed(KeyboardKey.Down)) fontSpacing += 0.1f; - else if (IsKeyPressed(KeyboardKey.PageUp)) lineSpacing -= 0.1f; - else if (IsKeyPressed(KeyboardKey.PageDown)) lineSpacing += 0.1f; - else if (IsKeyDown(KeyboardKey.Insert)) layerDistance -= 0.001f; - else if (IsKeyDown(KeyboardKey.Delete)) layerDistance += 0.001f; + if (IsKeyPressed(KeyboardKey.Left)) + { + fontSize -= 0.5f; + } + else if (IsKeyPressed(KeyboardKey.Right)) + { + fontSize += 0.5f; + } + else if (IsKeyPressed(KeyboardKey.Up)) + { + fontSpacing -= 0.1f; + } + else if (IsKeyPressed(KeyboardKey.Down)) + { + fontSpacing += 0.1f; + } + else if (IsKeyPressed(KeyboardKey.PageUp)) + { + lineSpacing -= 0.1f; + } + else if (IsKeyPressed(KeyboardKey.PageDown)) + { + lineSpacing += 0.1f; + } + else if (IsKeyDown(KeyboardKey.Insert)) + { + layerDistance -= 0.001f; + } + else if (IsKeyDown(KeyboardKey.Delete)) + { + layerDistance += 0.001f; + } else if (IsKeyPressed(KeyboardKey.Tab)) { multicolor = !multicolor; // Enable /disable multicolor mode @@ -258,17 +294,26 @@ public partial class Text3D : IExample if (IsKeyPressed(KeyboardKey.Backspace)) { // Remove last char - if (text.Length > 0) text = text.Substring(0, text.Length - 1); + if (text.Length > 0) + { + text = text.Substring(0, text.Length - 1); + } } else if (IsKeyPressed(KeyboardKey.Enter)) { // handle newline - if (text.Length < 63) text += '\n'; + if (text.Length < 63) + { + text += '\n'; + } } else { // append only printable chars - if ((ch != 0) && (text.Length < 63)) text += char.ConvertFromUtf32(ch); + if ((ch != 0) && (text.Length < 63)) + { + text += char.ConvertFromUtf32(ch); + } } // Measure 3D text so we can center it @@ -302,12 +347,20 @@ public partial class Text3D : IExample for (int i = 0; i < layers; i++) { Color clr = light; - if (multicolor) clr = multi[i]; + if (multicolor) + { + clr = multi[i]; + } + DrawTextWave3D(font, text, new Vector3(-tbox.X / 2.0f, layerDistance * i, -4.5f), fontSize, fontSpacing, lineSpacing, true, wcfg, time, clr); } // Draw the text boundry if set - if (showTextBoundry) DrawCubeWiresV(new Vector3(0.0f, 0.0f, -4.5f + tbox.Z / 2), tbox, dark); + if (showTextBoundry) + { + DrawCubeWiresV(new Vector3(0.0f, 0.0f, -4.5f + tbox.Z / 2), tbox, dark); + } + Rlgl.PopMatrix(); // Don't draw the letter boundries for the 3D text below @@ -490,7 +543,10 @@ public partial class Text3D : IExample float tw = (srcRec.X + srcRec.Width) / font.Texture.Width; float th = (srcRec.Y + srcRec.Height) / font.Texture.Height; - if (showLetterBoundry) DrawCubeWiresV(new Vector3(position.X + width / 2, position.Y, position.Z + height / 2), new Vector3(width, LetterBoundrySize, height), LetterBoundryColor); + if (showLetterBoundry) + { + DrawCubeWiresV(new Vector3(position.X + width / 2, position.Y, position.Z + height / 2), new Vector3(width, LetterBoundrySize, height), LetterBoundryColor); + } Rlgl.CheckRenderBatchLimit(4 + 4 * (backface ? 1 : 0)); Rlgl.SetTexture(font.Texture.Id); @@ -545,7 +601,10 @@ public partial class Text3D : IExample // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // but we need to draw all of the bad bytes using the '?' symbol moving one byte - if (codepoint == 0x3f) codepointByteCount = 1; + if (codepoint == 0x3f) + { + codepointByteCount = 1; + } if (codepoint == '\n') { @@ -561,8 +620,14 @@ public partial class Text3D : IExample DrawTextCodepoint3D(font, codepoint, new Vector3(position.X + textOffsetX, position.Y, position.Z + textOffsetY), fontSize, backface, tint); } - if (font.Glyphs[index].AdvanceX == 0) textOffsetX += font.Recs[index].Width * scale + fontSpacing; - else textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing; + if (font.Glyphs[index].AdvanceX == 0) + { + textOffsetX += font.Recs[index].Width * scale + fontSpacing; + } + else + { + textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing; + } } i += codepointByteCount; // Move text bytes counter to next codepoint @@ -593,7 +658,10 @@ public partial class Text3D : IExample // NOTE: Normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // but we need to draw all of the bad bytes using the '?' symbol moving one byte - if (codepoint == 0x3f) codepointByteCount = 1; + if (codepoint == 0x3f) + { + codepointByteCount = 1; + } if (codepoint == '\n') { @@ -626,8 +694,14 @@ public partial class Text3D : IExample DrawTextCodepoint3D(font, codepoint, new Vector3(pos.X + textOffsetX, pos.Y, pos.Z + textOffsetY), fontSize, backface, tint); } - if (font.Glyphs[index].AdvanceX == 0) textOffsetX += font.Recs[index].Width * scale + fontSpacing; - else textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing; + if (font.Glyphs[index].AdvanceX == 0) + { + textOffsetX += font.Recs[index].Width * scale + fontSpacing; + } + else + { + textOffsetX += font.Glyphs[index].AdvanceX * scale + fontSpacing; + } } i += codepointByteCount; // Move text bytes counter to next codepoint @@ -660,7 +734,11 @@ public partial class Text3D : IExample // NOTE: normally we exit the decoding sequence as soon as a bad byte is found (and return 0x3f) // but we need to draw all of the bad bytes using the '?' symbol so to not skip any we set next = 1 - if (letter == 0x3f) next = 1; + if (letter == 0x3f) + { + next = 1; + } + i += next - 1; if (letter != '\n') @@ -672,22 +750,38 @@ public partial class Text3D : IExample else { lenCounter++; - if (font.Glyphs[index].AdvanceX != 0) textWidth += font.Glyphs[index].AdvanceX * scale; - else textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX) * scale; + if (font.Glyphs[index].AdvanceX != 0) + { + textWidth += font.Glyphs[index].AdvanceX * scale; + } + else + { + textWidth += (font.Recs[index].Width + font.Glyphs[index].OffsetX) * scale; + } } } else { - if (tempTextWidth < textWidth) tempTextWidth = textWidth; + if (tempTextWidth < textWidth) + { + tempTextWidth = textWidth; + } + lenCounter = 0; textWidth = 0.0f; textHeight += fontSize + lineSpacing; } - if (tempLen < lenCounter) tempLen = lenCounter; + if (tempLen < lenCounter) + { + tempLen = lenCounter; + } } - if (tempTextWidth < textWidth) tempTextWidth = textWidth; + if (tempTextWidth < textWidth) + { + tempTextWidth = textWidth; + } Vector3 vec = new(0, 0, 0); vec.X = tempTextWidth + ((tempLen - 1) * fontSpacing); // Adds chars spacing to measure diff --git a/Examples/Text/UnicodeRanges.cs b/Examples/Text/UnicodeRanges.cs index 2979c73..33a09b6 100644 --- a/Examples/Text/UnicodeRanges.cs +++ b/Examples/Text/UnicodeRanges.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using Raylib_cs; -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class UnicodeRanges : IExample @@ -115,11 +111,26 @@ public partial class UnicodeRanges : IExample SetTextureFilter(font.Texture, TextureFilter.Bilinear); // Set font atlas scale filter } - if (IsKeyPressed(KeyboardKey.Zero)) unicodeRange = 0; - else if (IsKeyPressed(KeyboardKey.One)) unicodeRange = 1; - else if (IsKeyPressed(KeyboardKey.Two)) unicodeRange = 2; - else if (IsKeyPressed(KeyboardKey.Three)) unicodeRange = 3; - else if (IsKeyPressed(KeyboardKey.Four)) unicodeRange = 4; + if (IsKeyPressed(KeyboardKey.Zero)) + { + unicodeRange = 0; + } + else if (IsKeyPressed(KeyboardKey.One)) + { + unicodeRange = 1; + } + else if (IsKeyPressed(KeyboardKey.Two)) + { + unicodeRange = 2; + } + else if (IsKeyPressed(KeyboardKey.Three)) + { + unicodeRange = 3; + } + else if (IsKeyPressed(KeyboardKey.Four)) + { + unicodeRange = 4; + } //else if (IsKeyPressed(KeyboardKey.Five)) unicodeRange = 5; //---------------------------------------------------------------------------------- @@ -185,11 +196,16 @@ public partial class UnicodeRanges : IExample int[] updatedCodepoints = new int[updatedCodepointCount]; // Get current codepoint list - for (int i = 0; i < currentRangeSize; i++) updatedCodepoints[i] = font.Glyphs[i].Value; + for (int i = 0; i < currentRangeSize; i++) + { + updatedCodepoints[i] = font.Glyphs[i].Value; + } // Add new codepoints to list (provided range) for (int i = currentRangeSize; i < updatedCodepointCount; i++) + { updatedCodepoints[i] = start + (i - currentRangeSize); + } UnloadFont(font); font = LoadFontEx(fontPath, 32, updatedCodepoints, updatedCodepointCount); diff --git a/Examples/Text/WordsAlignment.cs b/Examples/Text/WordsAlignment.cs index 75c6e10..0e89e56 100644 --- a/Examples/Text/WordsAlignment.cs +++ b/Examples/Text/WordsAlignment.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; // Required for: Lerp() namespace Examples.Text; @@ -81,29 +79,47 @@ public partial class WordsAlignment : IExample //---------------------------------------------------------------------------------- if (IsKeyPressed(KeyboardKey.Left)) { - if (hAlign > 0) hAlign = hAlign - 1; + if (hAlign > 0) + { + hAlign = hAlign - 1; + } } if (IsKeyPressed(KeyboardKey.Right)) { hAlign = hAlign + 1; - if (hAlign > 2) hAlign = 2; + if (hAlign > 2) + { + hAlign = 2; + } } if (IsKeyPressed(KeyboardKey.Up)) { - if (vAlign > 0) vAlign = vAlign - 1; + if (vAlign > 0) + { + vAlign = vAlign - 1; + } } if (IsKeyPressed(KeyboardKey.Down)) { vAlign = vAlign + 1; - if (vAlign > 2) vAlign = 2; + if (vAlign > 2) + { + vAlign = 2; + } } // One word per second - if (wordCount > 0) wordIndex = (int)GetTime() % wordCount; - else wordIndex = 0; + if (wordCount > 0) + { + wordIndex = (int)GetTime() % wordCount; + } + else + { + wordIndex = 0; + } //---------------------------------------------------------------------------------- // Draw diff --git a/Examples/Text/WritingAnim.cs b/Examples/Text/WritingAnim.cs index a5c9382..9d10ec2 100644 --- a/Examples/Text/WritingAnim.cs +++ b/Examples/Text/WritingAnim.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Text; public partial class WritingAnim : IExample diff --git a/Examples/Textures/BackgroundScrolling.cs b/Examples/Textures/BackgroundScrolling.cs index 1f91529..42eb47a 100644 --- a/Examples/Textures/BackgroundScrolling.cs +++ b/Examples/Textures/BackgroundScrolling.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class BackgroundScrolling : IExample diff --git a/Examples/Textures/BlendModes.cs b/Examples/Textures/BlendModes.cs index a8f5665..87f9747 100644 --- a/Examples/Textures/BlendModes.cs +++ b/Examples/Textures/BlendModes.cs @@ -17,8 +17,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class BlendModes : IExample diff --git a/Examples/Textures/Bunnymark.cs b/Examples/Textures/Bunnymark.cs index 22304c5..a341565 100644 --- a/Examples/Textures/Bunnymark.cs +++ b/Examples/Textures/Bunnymark.cs @@ -14,8 +14,6 @@ ********************************************************************************************/ using System.Diagnostics; -using System.Numerics; -using static Raylib_cs.Raylib; namespace Examples.Textures; diff --git a/Examples/Textures/CellularAutomata.cs b/Examples/Textures/CellularAutomata.cs index ee558e9..244db8f 100644 --- a/Examples/Textures/CellularAutomata.cs +++ b/Examples/Textures/CellularAutomata.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class CellularAutomata : IExample diff --git a/Examples/Textures/ClipboardImage.cs b/Examples/Textures/ClipboardImage.cs index 3c0e157..41dadec 100644 --- a/Examples/Textures/ClipboardImage.cs +++ b/Examples/Textures/ClipboardImage.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; [ExcludeFromBrowser("GetClipboardImage() is a desktop-only OS clipboard feature")] diff --git a/Examples/Textures/DrawTiled.cs b/Examples/Textures/DrawTiled.cs index 1e59525..929670a 100644 --- a/Examples/Textures/DrawTiled.cs +++ b/Examples/Textures/DrawTiled.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class DrawTiled : IExample diff --git a/Examples/Textures/FogOfWar.cs b/Examples/Textures/FogOfWar.cs index 8d95eea..3eb7a29 100644 --- a/Examples/Textures/FogOfWar.cs +++ b/Examples/Textures/FogOfWar.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class FogOfWar : IExample diff --git a/Examples/Textures/FramebufferRendering.cs b/Examples/Textures/FramebufferRendering.cs index cd435d4..a641a08 100644 --- a/Examples/Textures/FramebufferRendering.cs +++ b/Examples/Textures/FramebufferRendering.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; using static Raylib_cs.Raymath; namespace Examples.Textures; diff --git a/Examples/Textures/GifPlayer.cs b/Examples/Textures/GifPlayer.cs index 62f5628..686ed0a 100644 --- a/Examples/Textures/GifPlayer.cs +++ b/Examples/Textures/GifPlayer.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class GifPlayer : IExample diff --git a/Examples/Textures/ImageChannel.cs b/Examples/Textures/ImageChannel.cs index 5741994..19c909c 100644 --- a/Examples/Textures/ImageChannel.cs +++ b/Examples/Textures/ImageChannel.cs @@ -17,9 +17,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageChannel : IExample diff --git a/Examples/Textures/ImageDrawing.cs b/Examples/Textures/ImageDrawing.cs index 25cee29..d2c046e 100644 --- a/Examples/Textures/ImageDrawing.cs +++ b/Examples/Textures/ImageDrawing.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageDrawing : IExample diff --git a/Examples/Textures/ImageGeneration.cs b/Examples/Textures/ImageGeneration.cs index 5cd901d..2f16b43 100644 --- a/Examples/Textures/ImageGeneration.cs +++ b/Examples/Textures/ImageGeneration.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageGeneration : IExample diff --git a/Examples/Textures/ImageKernel.cs b/Examples/Textures/ImageKernel.cs index 62cd563..58f416b 100644 --- a/Examples/Textures/ImageKernel.cs +++ b/Examples/Textures/ImageKernel.cs @@ -17,8 +17,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageKernel : IExample diff --git a/Examples/Textures/ImageLoading.cs b/Examples/Textures/ImageLoading.cs index d525900..5d57f24 100644 --- a/Examples/Textures/ImageLoading.cs +++ b/Examples/Textures/ImageLoading.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageLoading : IExample diff --git a/Examples/Textures/ImageProcessing.cs b/Examples/Textures/ImageProcessing.cs index 91b546d..f937df0 100644 --- a/Examples/Textures/ImageProcessing.cs +++ b/Examples/Textures/ImageProcessing.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageProcessing : IExample diff --git a/Examples/Textures/ImageRotate.cs b/Examples/Textures/ImageRotate.cs index 86c250a..30bb29c 100644 --- a/Examples/Textures/ImageRotate.cs +++ b/Examples/Textures/ImageRotate.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageRotate : IExample diff --git a/Examples/Textures/ImageText.cs b/Examples/Textures/ImageText.cs index cbed26e..abb3feb 100644 --- a/Examples/Textures/ImageText.cs +++ b/Examples/Textures/ImageText.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ImageText : IExample diff --git a/Examples/Textures/LogoRaylibTexture.cs b/Examples/Textures/LogoRaylibTexture.cs index 64b5a6c..5c78e74 100644 --- a/Examples/Textures/LogoRaylibTexture.cs +++ b/Examples/Textures/LogoRaylibTexture.cs @@ -13,8 +13,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class LogoRaylibTexture : IExample diff --git a/Examples/Textures/MagnifyingGlass.cs b/Examples/Textures/MagnifyingGlass.cs index 1c77d50..ee2686a 100644 --- a/Examples/Textures/MagnifyingGlass.cs +++ b/Examples/Textures/MagnifyingGlass.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class MagnifyingGlass : IExample diff --git a/Examples/Textures/MousePainting.cs b/Examples/Textures/MousePainting.cs index e828201..47f2efb 100644 --- a/Examples/Textures/MousePainting.cs +++ b/Examples/Textures/MousePainting.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class MousePainting : IExample diff --git a/Examples/Textures/NpatchDrawing.cs b/Examples/Textures/NpatchDrawing.cs index f641535..775f06b 100644 --- a/Examples/Textures/NpatchDrawing.cs +++ b/Examples/Textures/NpatchDrawing.cs @@ -17,10 +17,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class NpatchDrawing : IExample diff --git a/Examples/Textures/ParticlesBlending.cs b/Examples/Textures/ParticlesBlending.cs index 257eda9..721096f 100644 --- a/Examples/Textures/ParticlesBlending.cs +++ b/Examples/Textures/ParticlesBlending.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ParticlesBlending : IExample diff --git a/Examples/Textures/Polygon.cs b/Examples/Textures/Polygon.cs index 787a751..f7e602f 100644 --- a/Examples/Textures/Polygon.cs +++ b/Examples/Textures/Polygon.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class Polygon : IExample diff --git a/Examples/Textures/RawData.cs b/Examples/Textures/RawData.cs index 0af7ebe..de86d04 100644 --- a/Examples/Textures/RawData.cs +++ b/Examples/Textures/RawData.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class RawData : IExample diff --git a/Examples/Textures/ScreenBuffer.cs b/Examples/Textures/ScreenBuffer.cs index 2501434..2e84b59 100644 --- a/Examples/Textures/ScreenBuffer.cs +++ b/Examples/Textures/ScreenBuffer.cs @@ -15,9 +15,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ScreenBuffer : IExample diff --git a/Examples/Textures/SpriteAnim.cs b/Examples/Textures/SpriteAnim.cs index 099a0bf..9795bc8 100644 --- a/Examples/Textures/SpriteAnim.cs +++ b/Examples/Textures/SpriteAnim.cs @@ -13,10 +13,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class SpriteAnim : IExample diff --git a/Examples/Textures/SpriteButton.cs b/Examples/Textures/SpriteButton.cs index eb01ebf..3bcb01a 100644 --- a/Examples/Textures/SpriteButton.cs +++ b/Examples/Textures/SpriteButton.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class SpriteButton : IExample diff --git a/Examples/Textures/SpriteExplosion.cs b/Examples/Textures/SpriteExplosion.cs index fd7523a..5ad72b9 100644 --- a/Examples/Textures/SpriteExplosion.cs +++ b/Examples/Textures/SpriteExplosion.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class SpriteExplosion : IExample diff --git a/Examples/Textures/SpriteStacking.cs b/Examples/Textures/SpriteStacking.cs index 41e3de1..002235f 100644 --- a/Examples/Textures/SpriteStacking.cs +++ b/Examples/Textures/SpriteStacking.cs @@ -16,9 +16,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class SpriteStacking : IExample diff --git a/Examples/Textures/SrcRecDstRec.cs b/Examples/Textures/SrcRecDstRec.cs index ea97511..f0c31fd 100644 --- a/Examples/Textures/SrcRecDstRec.cs +++ b/Examples/Textures/SrcRecDstRec.cs @@ -13,9 +13,6 @@ * ********************************************************************************************/ -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class SrcRecDstRec : IExample diff --git a/Examples/Textures/TexturedCurve.cs b/Examples/Textures/TexturedCurve.cs index d2d1118..a1fab9c 100644 --- a/Examples/Textures/TexturedCurve.cs +++ b/Examples/Textures/TexturedCurve.cs @@ -15,10 +15,6 @@ * ********************************************************************************************/ -using System; -using System.Numerics; -using static Raylib_cs.Raylib; - namespace Examples.Textures; public unsafe partial class TexturedCurve : IExample diff --git a/Examples/Textures/ToImage.cs b/Examples/Textures/ToImage.cs index 9f71118..145748c 100644 --- a/Examples/Textures/ToImage.cs +++ b/Examples/Textures/ToImage.cs @@ -15,8 +15,6 @@ * ********************************************************************************************/ -using static Raylib_cs.Raylib; - namespace Examples.Textures; public partial class ToImage : IExample