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

chore: clean up linter warnings

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

View file

@ -15,10 +15,6 @@
* *
********************************************************************************************/ ********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Audio; namespace Examples.Audio;
public unsafe partial class AmpEnvelope : IExample public unsafe partial class AmpEnvelope : IExample
@ -89,9 +85,15 @@ public unsafe partial class AmpEnvelope : IExample
{ {
// Update // 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)) if (IsAudioStreamProcessed(stream))
{ {
@ -106,7 +108,11 @@ public unsafe partial class AmpEnvelope : IExample
else else
{ {
// Clear buffer if silent to avoid looping noise // 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; audioTime = 0.0f;
} }
@ -116,7 +122,10 @@ public unsafe partial class AmpEnvelope : IExample
} }
} }
if (!IsAudioStreamPlaying(stream)) PlayAudioStream(stream); if (!IsAudioStreamPlaying(stream))
{
PlayAudioStream(stream);
}
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -15,8 +15,6 @@
* *
********************************************************************************************/ ********************************************************************************************/
using static Raylib_cs.Raylib;
namespace Examples.Audio; namespace Examples.Audio;
public partial class SoundMulti : IExample public partial class SoundMulti : IExample
@ -42,7 +40,10 @@ public partial class SoundMulti : IExample
soundArray[0] = LoadSound("resources/audio/sound.wav"); 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 // 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 currentSound = 0; // Set the sound list to the start
} }
@ -57,7 +58,10 @@ public partial class SoundMulti : IExample
currentSound++; // Increment the sound slot currentSound++; // Increment the sound slot
// If the sound slot is out of bounds, go back to 0 // 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 // NOTE: Another approach would be to look at the list for the first sound
// that is not playing and use that slot // that is not playing and use that slot
@ -78,7 +82,11 @@ public partial class SoundMulti : IExample
public void Unload() 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 UnloadSound(soundArray[0]); // Unload source sound data
CloseAudioDevice(); // Close audio device CloseAudioDevice(); // Close audio device

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,10 +17,7 @@
// raygui is not bound in raylib-cs, so the widgets below are minimal re-implementations // 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 plain raylib drawing/input. The hashing/Base64 logic is a faithful port.
using System;
using System.Numerics;
using System.Text; using System.Text;
using static Raylib_cs.Raylib;
namespace Examples.Core; namespace Examples.Core;
@ -101,7 +98,10 @@ public unsafe partial class ComputeHash : IExample
GuiLabel(new Rectangle(40, 26, 720, 32), "INPUT DATA (TEXT):", 20); 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); 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) private static uint[] CopyHash(uint* data, int count)
{ {
if (data == null) return null; if (data == null)
{
return null;
}
uint[] result = new uint[count]; 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; return result;
} }
@ -145,7 +152,11 @@ public unsafe partial class ComputeHash : IExample
if ((data != null) && (dataSize > 0) && (dataSize < ((128 / 8) - 1))) if ((data != null) && (dataSize > 0) && (dataSize < ((128 / 8) - 1)))
{ {
StringBuilder text = new StringBuilder(); 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(); return text.ToString();
} }
@ -173,7 +184,10 @@ public unsafe partial class ComputeHash : IExample
int textWidth = MeasureText(text, fontSize); int textWidth = MeasureText(text, fontSize);
DrawText(text, (int)(bounds.X + (bounds.Width - textWidth) / 2), (int)(bounds.Y + (bounds.Height - fontSize) / 2), fontSize, Color.DarkGray); 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; return pressed;
} }
@ -197,7 +211,10 @@ public unsafe partial class ComputeHash : IExample
key = GetCharPressed(); 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); 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); 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; return pressed;
} }
@ -220,7 +240,10 @@ public unsafe partial class ComputeHash : IExample
{ {
DrawRectangleRec(bounds, Color.LightGray); DrawRectangleRec(bounds, Color.LightGray);
DrawRectangleLinesEx(bounds, 1, Color.Gray); 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() public static int Main()

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -19,9 +19,6 @@
// For example instead of using `IsKeyDown(KEY_LEFT)`, you can use `IsActionDown(ACTION_LEFT)` // For example instead of using `IsKeyDown(KEY_LEFT)`, you can use `IsActionDown(ACTION_LEFT)`
// which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys // which can be reassigned to e.g. KEY_A and also assigned to a gamepad button. the action will trigger with either gamepad or keys
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core; namespace Examples.Core;
public partial class InputActions : IExample public partial class InputActions : IExample
@ -82,10 +79,26 @@ public partial class InputActions : IExample
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
gamepadIndex = 0; // Set gamepad being checked gamepadIndex = 0; // Set gamepad being checked
if (IsActionDown(ActionType.ActionUp)) position.Y -= 2; if (IsActionDown(ActionType.ActionUp))
if (IsActionDown(ActionType.ActionDown)) position.Y += 2; {
if (IsActionDown(ActionType.ActionLeft)) position.X -= 2; position.Y -= 2;
if (IsActionDown(ActionType.ActionRight)) position.X += 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)) if (IsActionPressed(ActionType.ActionFire))
{ {
position.X = (screenWidth - size.X) / 2; position.X = (screenWidth - size.X) / 2;
@ -94,14 +107,23 @@ public partial class InputActions : IExample
// Register release action for one frame // Register release action for one frame
releaseAction = false; releaseAction = false;
if (IsActionReleased(ActionType.ActionFire)) releaseAction = true; if (IsActionReleased(ActionType.ActionFire))
{
releaseAction = true;
}
// Switch control scheme by pressing TAB // Switch control scheme by pressing TAB
if (IsKeyPressed(KeyboardKey.Tab)) if (IsKeyPressed(KeyboardKey.Tab))
{ {
actionSet = (actionSet == 0) ? 1 : 0; actionSet = (actionSet == 0) ? 1 : 0;
if (actionSet == 0) SetActionsDefault(); if (actionSet == 0)
else SetActionsCursor(); {
SetActionsDefault();
}
else
{
SetActionsCursor();
}
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
@ -133,7 +155,10 @@ public partial class InputActions : IExample
{ {
bool result = false; 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; return result;
} }
@ -144,7 +169,10 @@ public partial class InputActions : IExample
{ {
bool result = false; 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; return result;
} }
@ -155,7 +183,10 @@ public partial class InputActions : IExample
{ {
bool result = false; 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; return result;
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,9 +16,6 @@
* *
********************************************************************************************/ ********************************************************************************************/
using System.Numerics;
using static Raylib_cs.Raylib;
namespace Examples.Core; namespace Examples.Core;
public partial class KeyboardTestbed : IExample public partial class KeyboardTestbed : IExample
@ -53,7 +50,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 01 // Keyboard line 01
line01KeyWidths = new int[15]; 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 line01KeyWidths[13] = 62; // PRINTSCREEN
line01Keys = new int[] line01Keys = new int[]
{ {
@ -64,7 +65,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 02 // Keyboard line 02
line02KeyWidths = new int[15]; 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[0] = 25; // GRAVE
line02KeyWidths[13] = 82; // BACKSPACE line02KeyWidths[13] = 82; // BACKSPACE
line02Keys = new int[] line02Keys = new int[]
@ -76,7 +81,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 03 // Keyboard line 03
line03KeyWidths = new int[15]; 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[0] = 50; // TAB
line03KeyWidths[13] = 57; // BACKSLASH line03KeyWidths[13] = 57; // BACKSLASH
line03Keys = new int[] line03Keys = new int[]
@ -88,7 +97,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 04 // Keyboard line 04
line04KeyWidths = new int[14]; 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[0] = 68; // CAPS
line04KeyWidths[12] = 88; // ENTER line04KeyWidths[12] = 88; // ENTER
line04Keys = new int[] line04Keys = new int[]
@ -100,7 +113,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 05 // Keyboard line 05
line05KeyWidths = new int[14]; 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[0] = 80; // LSHIFT
line05KeyWidths[11] = 76; // RSHIFT line05KeyWidths[11] = 76; // RSHIFT
line05Keys = new int[] line05Keys = new int[]
@ -112,7 +129,11 @@ public partial class KeyboardTestbed : IExample
// Keyboard line 06 // Keyboard line 06
line06KeyWidths = new int[11]; 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[0] = 80; // LCTRL
line06KeyWidths[3] = 208; // SPACE line06KeyWidths[3] = 208; // SPACE
line06KeyWidths[7] = 60; // RCTRL line06KeyWidths[7] = 60; // RCTRL
@ -131,10 +152,16 @@ public partial class KeyboardTestbed : IExample
// Update // Update
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
int key = GetKeyPressed(); // Get pressed keycode 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 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 // Draw
@ -322,7 +349,10 @@ public partial class KeyboardTestbed : IExample
// Draw keyboard key // Draw keyboard key
private static void GuiKeyboardKey(Rectangle bounds, int 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 else
{ {
if (IsKeyDown((KeyboardKey)key)) if (IsKeyDown((KeyboardKey)key))

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -17,9 +17,6 @@
* *
********************************************************************************************/ ********************************************************************************************/
using System;
using System.Numerics;
using static Raylib_cs.Raylib;
using static Raylib_cs.Raymath; using static Raylib_cs.Raymath;
namespace Examples.Models; 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); 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) // 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(); EndMode3D();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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