chore: clean up linter warnings
This commit is contained in:
parent
23b3659b1b
commit
dfc34997bc
217 changed files with 1863 additions and 1077 deletions
|
|
@ -15,10 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public unsafe partial class AmpEnvelope : IExample
|
||||
|
|
@ -89,9 +85,15 @@ public unsafe partial class AmpEnvelope : IExample
|
|||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KeyboardKey.Space)) env.State = ADSRState.Attack;
|
||||
if (IsKeyPressed(KeyboardKey.Space))
|
||||
{
|
||||
env.State = ADSRState.Attack;
|
||||
}
|
||||
|
||||
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle)) env.State = ADSRState.Release;
|
||||
if (IsKeyReleased(KeyboardKey.Space) && (env.State != ADSRState.Idle))
|
||||
{
|
||||
env.State = ADSRState.Release;
|
||||
}
|
||||
|
||||
if (IsAudioStreamProcessed(stream))
|
||||
{
|
||||
|
|
@ -106,7 +108,11 @@ public unsafe partial class AmpEnvelope : IExample
|
|||
else
|
||||
{
|
||||
// Clear buffer if silent to avoid looping noise
|
||||
for (int i = 0; i < BUFFER_SIZE; i++) buffer[i] = 0;
|
||||
for (int i = 0; i < BUFFER_SIZE; i++)
|
||||
{
|
||||
buffer[i] = 0;
|
||||
}
|
||||
|
||||
audioTime = 0.0f;
|
||||
}
|
||||
|
||||
|
|
@ -116,7 +122,10 @@ public unsafe partial class AmpEnvelope : IExample
|
|||
}
|
||||
}
|
||||
|
||||
if (!IsAudioStreamPlaying(stream)) PlayAudioStream(stream);
|
||||
if (!IsAudioStreamPlaying(stream))
|
||||
{
|
||||
PlayAudioStream(stream);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
|
|||
|
|
@ -15,10 +15,8 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
|
|
@ -60,7 +58,10 @@ public unsafe partial class MixedProcessor : IExample
|
|||
}
|
||||
|
||||
// Moving history to the left
|
||||
for (int i = 0; i < 399; i++) averageVolume[i] = averageVolume[i + 1];
|
||||
for (int i = 0; i < 399; i++)
|
||||
{
|
||||
averageVolume[i] = averageVolume[i + 1];
|
||||
}
|
||||
|
||||
averageVolume[399] = average; // Adding last average value
|
||||
}
|
||||
|
|
@ -88,13 +89,30 @@ public unsafe partial class MixedProcessor : IExample
|
|||
|
||||
// Modify processing variables
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyPressed(KeyboardKey.Left)) exponent -= 0.05f;
|
||||
if (IsKeyPressed(KeyboardKey.Right)) exponent += 0.05f;
|
||||
if (IsKeyPressed(KeyboardKey.Left))
|
||||
{
|
||||
exponent -= 0.05f;
|
||||
}
|
||||
|
||||
if (exponent <= 0.5f) exponent = 0.5f;
|
||||
if (exponent >= 3.0f) exponent = 3.0f;
|
||||
if (IsKeyPressed(KeyboardKey.Right))
|
||||
{
|
||||
exponent += 0.05f;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KeyboardKey.Space)) PlaySound(sound);
|
||||
if (exponent <= 0.5f)
|
||||
{
|
||||
exponent = 0.5f;
|
||||
}
|
||||
|
||||
if (exponent >= 3.0f)
|
||||
{
|
||||
exponent = 3.0f;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KeyboardKey.Space))
|
||||
{
|
||||
PlaySound(sound);
|
||||
}
|
||||
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public partial class ModulePlaying : IExample
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public partial class MusicStreamDemo : IExample
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public unsafe partial class RawStream : IExample
|
||||
|
|
@ -71,26 +67,40 @@ public unsafe partial class RawStream : IExample
|
|||
if (IsKeyDown(KeyboardKey.Up))
|
||||
{
|
||||
newSineFrequency += 10;
|
||||
if (newSineFrequency > 12500) newSineFrequency = 12500;
|
||||
if (newSineFrequency > 12500)
|
||||
{
|
||||
newSineFrequency = 12500;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Down))
|
||||
{
|
||||
newSineFrequency -= 10;
|
||||
if (newSineFrequency < 20) newSineFrequency = 20;
|
||||
if (newSineFrequency < 20)
|
||||
{
|
||||
newSineFrequency = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Left))
|
||||
{
|
||||
pan -= 0.01f;
|
||||
if (pan < -1.0f) pan = -1.0f;
|
||||
if (pan < -1.0f)
|
||||
{
|
||||
pan = -1.0f;
|
||||
}
|
||||
|
||||
SetAudioStreamPan(stream, pan);
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Right))
|
||||
{
|
||||
pan += 0.01f;
|
||||
if (pan > 1.0f) pan = 1.0f;
|
||||
if (pan > 1.0f)
|
||||
{
|
||||
pan = 1.0f;
|
||||
}
|
||||
|
||||
SetAudioStreamPan(stream, pan);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public partial class SoundLoading : IExample
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public partial class SoundMulti : IExample
|
||||
|
|
@ -42,7 +40,10 @@ public partial class SoundMulti : IExample
|
|||
soundArray[0] = LoadSound("resources/audio/sound.wav");
|
||||
|
||||
// Load an alias of the sound into slots 1-9. These do not own the sound data, but can be played
|
||||
for (int i = 1; i < MAX_SOUNDS; i++) soundArray[i] = LoadSoundAlias(soundArray[0]);
|
||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||
{
|
||||
soundArray[i] = LoadSoundAlias(soundArray[0]);
|
||||
}
|
||||
|
||||
currentSound = 0; // Set the sound list to the start
|
||||
}
|
||||
|
|
@ -57,7 +58,10 @@ public partial class SoundMulti : IExample
|
|||
currentSound++; // Increment the sound slot
|
||||
|
||||
// If the sound slot is out of bounds, go back to 0
|
||||
if (currentSound >= MAX_SOUNDS) currentSound = 0;
|
||||
if (currentSound >= MAX_SOUNDS)
|
||||
{
|
||||
currentSound = 0;
|
||||
}
|
||||
|
||||
// NOTE: Another approach would be to look at the list for the first sound
|
||||
// that is not playing and use that slot
|
||||
|
|
@ -78,7 +82,11 @@ public partial class SoundMulti : IExample
|
|||
|
||||
public void Unload()
|
||||
{
|
||||
for (int i = 1; i < MAX_SOUNDS; i++) UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||
for (int i = 1; i < MAX_SOUNDS; i++)
|
||||
{
|
||||
UnloadSoundAlias(soundArray[i]); // Unload sound aliases
|
||||
}
|
||||
|
||||
UnloadSound(soundArray[0]); // Unload source sound data
|
||||
|
||||
CloseAudioDevice(); // Close audio device
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
public partial class SoundPositioning : IExample
|
||||
|
|
@ -67,7 +63,10 @@ public partial class SoundPositioning : IExample
|
|||
|
||||
SetSoundPosition(camera, sound, spherePos, 1.0f);
|
||||
|
||||
if (!IsSoundPlaying(sound)) PlaySound(sound);
|
||||
if (!IsSoundPlaying(sound))
|
||||
{
|
||||
PlaySound(sound);
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -112,7 +111,10 @@ public partial class SoundPositioning : IExample
|
|||
|
||||
// Reduce volume for sounds behind the listener
|
||||
float dotProduct = Vector3.Dot(forward, normalizedDirection);
|
||||
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct * 0.5f);
|
||||
if (dotProduct < 0.0f)
|
||||
{
|
||||
attenuation *= (1.0f + dotProduct * 0.5f);
|
||||
}
|
||||
|
||||
// Set stereo panning based on sound position relative to listener
|
||||
float pan = 0.5f + 0.5f * Vector3.Dot(normalizedDirection, right);
|
||||
|
|
|
|||
|
|
@ -20,11 +20,8 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
|
|
@ -105,31 +102,61 @@ public unsafe partial class StreamCallback : IExample
|
|||
if (IsKeyDown(KeyboardKey.Up))
|
||||
{
|
||||
newWaveFrequency += 10;
|
||||
if (newWaveFrequency > 12500) newWaveFrequency = 12500;
|
||||
if (newWaveFrequency > 12500)
|
||||
{
|
||||
newWaveFrequency = 12500;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Down))
|
||||
{
|
||||
newWaveFrequency -= 10;
|
||||
if (newWaveFrequency < 20) newWaveFrequency = 20;
|
||||
if (newWaveFrequency < 20)
|
||||
{
|
||||
newWaveFrequency = 20;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KeyboardKey.Left))
|
||||
{
|
||||
if (waveType == WaveType.Sine) waveType = WaveType.Sawtooth;
|
||||
else if (waveType == WaveType.Square) waveType = WaveType.Sine;
|
||||
else if (waveType == WaveType.Triangle) waveType = WaveType.Square;
|
||||
else waveType = WaveType.Triangle;
|
||||
if (waveType == WaveType.Sine)
|
||||
{
|
||||
waveType = WaveType.Sawtooth;
|
||||
}
|
||||
else if (waveType == WaveType.Square)
|
||||
{
|
||||
waveType = WaveType.Sine;
|
||||
}
|
||||
else if (waveType == WaveType.Triangle)
|
||||
{
|
||||
waveType = WaveType.Square;
|
||||
}
|
||||
else
|
||||
{
|
||||
waveType = WaveType.Triangle;
|
||||
}
|
||||
|
||||
SetWaveCallback();
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KeyboardKey.Right))
|
||||
{
|
||||
if (waveType == WaveType.Sine) waveType = WaveType.Square;
|
||||
else if (waveType == WaveType.Square) waveType = WaveType.Triangle;
|
||||
else if (waveType == WaveType.Triangle) waveType = WaveType.Sawtooth;
|
||||
else waveType = WaveType.Sine;
|
||||
if (waveType == WaveType.Sine)
|
||||
{
|
||||
waveType = WaveType.Square;
|
||||
}
|
||||
else if (waveType == WaveType.Square)
|
||||
{
|
||||
waveType = WaveType.Triangle;
|
||||
}
|
||||
else if (waveType == WaveType.Triangle)
|
||||
{
|
||||
waveType = WaveType.Sawtooth;
|
||||
}
|
||||
else
|
||||
{
|
||||
waveType = WaveType.Sine;
|
||||
}
|
||||
|
||||
SetWaveCallback();
|
||||
}
|
||||
|
|
@ -197,8 +224,15 @@ public unsafe partial class StreamCallback : IExample
|
|||
}
|
||||
|
||||
// Save the synthesized samples for later drawing
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
|
||||
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++)
|
||||
{
|
||||
buffer[i] = buffer[i + fc];
|
||||
}
|
||||
|
||||
for (int i = 0; i < fc; i++)
|
||||
{
|
||||
buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
|
|
@ -222,8 +256,15 @@ public unsafe partial class StreamCallback : IExample
|
|||
}
|
||||
|
||||
// Save the synthesized samples for later drawing
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
|
||||
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++)
|
||||
{
|
||||
buffer[i] = buffer[i + fc];
|
||||
}
|
||||
|
||||
for (int i = 0; i < fc; i++)
|
||||
{
|
||||
buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
|
|
@ -247,8 +288,15 @@ public unsafe partial class StreamCallback : IExample
|
|||
}
|
||||
|
||||
// Save the synthesized samples for later drawing
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
|
||||
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++)
|
||||
{
|
||||
buffer[i] = buffer[i + fc];
|
||||
}
|
||||
|
||||
for (int i = 0; i < fc; i++)
|
||||
{
|
||||
buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
}
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly(CallConvs = new[] { typeof(CallConvCdecl) })]
|
||||
|
|
@ -272,8 +320,15 @@ public unsafe partial class StreamCallback : IExample
|
|||
}
|
||||
|
||||
// Save the synthesized samples for later drawing
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++) buffer[i] = buffer[i + fc];
|
||||
for (int i = 0; i < fc; i++) buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
for (int i = 0; i < SAMPLE_RATE - fc; i++)
|
||||
{
|
||||
buffer[i] = buffer[i + fc];
|
||||
}
|
||||
|
||||
for (int i = 0; i < fc; i++)
|
||||
{
|
||||
buffer[SAMPLE_RATE - fc + i] = frames[i];
|
||||
}
|
||||
}
|
||||
|
||||
public static int Main()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Audio;
|
||||
|
||||
|
|
@ -87,30 +86,51 @@ public unsafe partial class StreamEffects : IExample
|
|||
{
|
||||
pause = !pause;
|
||||
|
||||
if (pause) PauseMusicStream(music);
|
||||
else ResumeMusicStream(music);
|
||||
if (pause)
|
||||
{
|
||||
PauseMusicStream(music);
|
||||
}
|
||||
else
|
||||
{
|
||||
ResumeMusicStream(music);
|
||||
}
|
||||
}
|
||||
|
||||
// Add/Remove effect: lowpass filter
|
||||
if (IsKeyPressed(KeyboardKey.F))
|
||||
{
|
||||
enableEffectLPF = !enableEffectLPF;
|
||||
if (enableEffectLPF) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
|
||||
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
|
||||
if (enableEffectLPF)
|
||||
{
|
||||
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
|
||||
}
|
||||
else
|
||||
{
|
||||
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectLPF);
|
||||
}
|
||||
}
|
||||
|
||||
// Add/Remove effect: delay
|
||||
if (IsKeyPressed(KeyboardKey.D))
|
||||
{
|
||||
enableEffectDelay = !enableEffectDelay;
|
||||
if (enableEffectDelay) AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
|
||||
else DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
|
||||
if (enableEffectDelay)
|
||||
{
|
||||
AttachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
|
||||
}
|
||||
else
|
||||
{
|
||||
DetachAudioStreamProcessor(music.Stream, &AudioProcessEffectDelay);
|
||||
}
|
||||
}
|
||||
|
||||
// Get normalized time played for current music stream
|
||||
timePlayed = GetMusicTimePlayed(music) / GetMusicTimeLength(music);
|
||||
|
||||
if (timePlayed > 1.0f) timePlayed = 1.0f; // Make sure time played is no longer than music
|
||||
if (timePlayed > 1.0f)
|
||||
{
|
||||
timePlayed = 1.0f; // Make sure time played is no longer than music
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -180,14 +200,20 @@ public unsafe partial class StreamEffects : IExample
|
|||
float leftDelay = delay[delayReadIndex++]; // ERROR: Reading buffer -> WHY??? Maybe thread related???
|
||||
float rightDelay = delay[delayReadIndex++];
|
||||
|
||||
if (delayReadIndex == delayBufferSize) delayReadIndex = 0;
|
||||
if (delayReadIndex == delayBufferSize)
|
||||
{
|
||||
delayReadIndex = 0;
|
||||
}
|
||||
|
||||
bufferData[i] = 0.5f * bufferData[i] + 0.5f * leftDelay;
|
||||
bufferData[i + 1] = 0.5f * bufferData[i + 1] + 0.5f * rightDelay;
|
||||
|
||||
delay[delayWriteIndex++] = bufferData[i];
|
||||
delay[delayWriteIndex++] = bufferData[i + 1];
|
||||
if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0;
|
||||
if (delayWriteIndex == delayBufferSize)
|
||||
{
|
||||
delayWriteIndex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,10 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class AutomationEvents : IExample
|
||||
|
|
@ -143,8 +139,16 @@ public partial class AutomationEvents : IExample
|
|||
|
||||
// Update player
|
||||
//----------------------------------------------------------------------------------
|
||||
if (IsKeyDown(KeyboardKey.Left)) player.Position.X -= PLAYER_HOR_SPD * deltaTime;
|
||||
if (IsKeyDown(KeyboardKey.Right)) player.Position.X += PLAYER_HOR_SPD * deltaTime;
|
||||
if (IsKeyDown(KeyboardKey.Left))
|
||||
{
|
||||
player.Position.X -= PLAYER_HOR_SPD * deltaTime;
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Right))
|
||||
{
|
||||
player.Position.X += PLAYER_HOR_SPD * deltaTime;
|
||||
}
|
||||
|
||||
if (IsKeyDown(KeyboardKey.Space) && player.CanJump)
|
||||
{
|
||||
player.Speed = -PLAYER_JUMP_SPD;
|
||||
|
|
@ -173,7 +177,10 @@ public partial class AutomationEvents : IExample
|
|||
player.Speed += GRAVITY * deltaTime;
|
||||
player.CanJump = false;
|
||||
}
|
||||
else player.CanJump = true;
|
||||
else
|
||||
{
|
||||
player.CanJump = true;
|
||||
}
|
||||
|
||||
if (IsKeyPressed(KeyboardKey.R))
|
||||
{
|
||||
|
|
@ -224,8 +231,14 @@ public partial class AutomationEvents : IExample
|
|||
|
||||
// WARNING: On event replay, mouse-wheel internal value is set
|
||||
camera.Zoom += ((float)GetMouseWheelMove() * 0.05f);
|
||||
if (camera.Zoom > 3.0f) camera.Zoom = 3.0f;
|
||||
else if (camera.Zoom < 0.25f) camera.Zoom = 0.25f;
|
||||
if (camera.Zoom > 3.0f)
|
||||
{
|
||||
camera.Zoom = 3.0f;
|
||||
}
|
||||
else if (camera.Zoom < 0.25f)
|
||||
{
|
||||
camera.Zoom = 0.25f;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_ENVIRONMENT_ELEMENTS; i++)
|
||||
{
|
||||
|
|
@ -239,10 +252,25 @@ public partial class AutomationEvents : IExample
|
|||
Vector2 max = GetWorldToScreen2D(new Vector2(maxX, maxY), camera);
|
||||
Vector2 min = GetWorldToScreen2D(new Vector2(minX, minY), camera);
|
||||
|
||||
if (max.X < screenWidth) camera.Offset.X = screenWidth - (max.X - (float)screenWidth / 2);
|
||||
if (max.Y < screenHeight) camera.Offset.Y = screenHeight - (max.Y - (float)screenHeight / 2);
|
||||
if (min.X > 0) camera.Offset.X = (float)screenWidth / 2 - min.X;
|
||||
if (min.Y > 0) camera.Offset.Y = (float)screenHeight / 2 - min.Y;
|
||||
if (max.X < screenWidth)
|
||||
{
|
||||
camera.Offset.X = screenWidth - (max.X - (float)screenWidth / 2);
|
||||
}
|
||||
|
||||
if (max.Y < screenHeight)
|
||||
{
|
||||
camera.Offset.Y = screenHeight - (max.Y - (float)screenHeight / 2);
|
||||
}
|
||||
|
||||
if (min.X > 0)
|
||||
{
|
||||
camera.Offset.X = (float)screenWidth / 2 - min.X;
|
||||
}
|
||||
|
||||
if (min.Y > 0)
|
||||
{
|
||||
camera.Offset.Y = (float)screenHeight / 2 - min.Y;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Events management
|
||||
|
|
@ -287,8 +315,14 @@ public partial class AutomationEvents : IExample
|
|||
}
|
||||
}
|
||||
|
||||
if (eventRecording || eventPlaying) frameCounter++;
|
||||
else frameCounter = 0;
|
||||
if (eventRecording || eventPlaying)
|
||||
{
|
||||
frameCounter++;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameCounter = 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
// Draw
|
||||
|
|
@ -329,7 +363,10 @@ public partial class AutomationEvents : IExample
|
|||
DrawRectangleLines(10, 160, 290, 30, Fade(Color.Maroon, 0.8f));
|
||||
DrawCircle(30, 175, 10, Color.Maroon);
|
||||
|
||||
if (((frameCounter / 15) % 2) == 1) DrawText($"RECORDING EVENTS... [{aelist.Count}]", 50, 170, 10, Color.Maroon);
|
||||
if (((frameCounter / 15) % 2) == 1)
|
||||
{
|
||||
DrawText($"RECORDING EVENTS... [{aelist.Count}]", 50, 170, 10, Color.Maroon);
|
||||
}
|
||||
}
|
||||
else if (eventPlaying)
|
||||
{
|
||||
|
|
@ -337,7 +374,10 @@ public partial class AutomationEvents : IExample
|
|||
DrawRectangleLines(10, 160, 290, 30, Fade(Color.DarkGreen, 0.8f));
|
||||
DrawTriangle(new Vector2(20, 155 + 10), new Vector2(20, 155 + 30), new Vector2(40, 155 + 20), Color.DarkGreen);
|
||||
|
||||
if (((frameCounter / 15) % 2) == 1) DrawText($"PLAYING RECORDED EVENTS... [{currentPlayFrame}]", 50, 170, 10, Color.DarkGreen);
|
||||
if (((frameCounter / 15) % 2) == 1)
|
||||
{
|
||||
DrawText($"PLAYING RECORDED EVENTS... [{currentPlayFrame}]", 50, 170, 10, Color.DarkGreen);
|
||||
}
|
||||
}
|
||||
|
||||
EndDrawing();
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
internal enum GameScreen
|
||||
|
|
|
|||
|
|
@ -26,11 +26,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
using System;
|
||||
using System.Text;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class BasicWindow : IExample
|
||||
|
|
|
|||
|
|
@ -13,10 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class Camera2dDemo : IExample
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
using static Raylib_cs.Raymath;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
using static Raylib_cs.Raymath;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class Camera3dFirstPerson : IExample
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
using static Raylib_cs.Raymath;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
|
@ -167,11 +164,17 @@ public partial class Camera3dFps : IExample
|
|||
// `#define NORMALIZE_INPUT 0` above it (defined() tests definedness, not the value), so the
|
||||
// diagonal-movement normalization is active.
|
||||
// Slow down diagonal movement
|
||||
if ((side != 0) && (forward != 0)) input = Vector2Normalize(input);
|
||||
if ((side != 0) && (forward != 0))
|
||||
{
|
||||
input = Vector2Normalize(input);
|
||||
}
|
||||
|
||||
float delta = GetFrameTime();
|
||||
|
||||
if (!body.IsGrounded) body.Velocity.Y -= GRAVITY * delta;
|
||||
if (!body.IsGrounded)
|
||||
{
|
||||
body.Velocity.Y -= GRAVITY * delta;
|
||||
}
|
||||
|
||||
if (body.IsGrounded && jumpPressed)
|
||||
{
|
||||
|
|
@ -196,7 +199,10 @@ public partial class Camera3dFps : IExample
|
|||
Vector3 hvel = new Vector3(body.Velocity.X * decel, 0.0f, body.Velocity.Z * decel);
|
||||
|
||||
float hvelLength = Vector3Length(hvel); // Magnitude
|
||||
if (hvelLength < (MAX_SPEED * 0.01f)) hvel = new Vector3(0, 0, 0);
|
||||
if (hvelLength < (MAX_SPEED * 0.01f))
|
||||
{
|
||||
hvel = new Vector3(0, 0, 0);
|
||||
}
|
||||
|
||||
// This is what creates strafing
|
||||
float speed = Vector3DotProduct(hvel, body.Dir);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class Camera3dFree : IExample
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@
|
|||
*
|
||||
********************************************************************************************/
|
||||
|
||||
using System.Numerics;
|
||||
using static Raylib_cs.Raylib;
|
||||
|
||||
namespace Examples.Core;
|
||||
|
||||
public partial class Camera3dMode : IExample
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue