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

Update tests and dll resolver (#336)

This commit is contained in:
Rgebee 2026-05-17 19:24:49 +01:00 committed by GitHub
commit a657bb6367
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 94 deletions

View file

@ -31,10 +31,16 @@ public static class Bunnymark
private record struct Bunny()
{
public Vector2 Position { get; set; } = GetMousePosition();
public Vector2 Speed { get; set; } = new(
public Vector2 Speed
{
get; set;
} = new(
GetRandomValue(-250, 250) / (float)TARGET_FPS,
GetRandomValue(-250, 250) / (float)TARGET_FPS);
public Color Color { get; } = new(
public Color Color
{
get;
} = new(
GetRandomValue(50, 240),
GetRandomValue(80, 240),
GetRandomValue(100, 240), 255);
@ -68,7 +74,7 @@ public static class Bunnymark
if (IsMouseButtonDown(MouseButton.Left) && bunniesCount < MaxBunnies)
{
// Add a range of new bunnies
foreach (ref var bunny in bunnies[bunniesCount..(bunniesCount+BunnyIncrement)])
foreach (ref var bunny in bunnies[bunniesCount..(bunniesCount + BunnyIncrement)])
{
bunny = new();
}
@ -79,7 +85,7 @@ public static class Bunnymark
// Remove the oldest bunnies, shifting them back in the span
if (bunniesCount > BunnyDecrement)
{
bunnies[BunnyDecrement .. bunniesCount].CopyTo(bunnies);
bunnies[BunnyDecrement..bunniesCount].CopyTo(bunnies);
}
bunniesCount = Math.Max(0, bunniesCount - BunnyDecrement);
}
@ -93,9 +99,9 @@ public static class Bunnymark
// Bounce bunnies off the screen borders
bunny.Speed *= (bunny.Position + halfSize) switch
{
{ X: < 0 or > screenWidth, Y: < 40 or > screenHeight} => new(-1, -1),
{ X: < 0 or > screenWidth} => new(-1, 1),
{ Y: < 40 or > screenHeight} => new(1,-1),
{ X: < 0 or > screenWidth, Y: < 40 or > screenHeight } => new(-1, -1),
{ X: < 0 or > screenWidth } => new(-1, 1),
{ Y: < 40 or > screenHeight } => new(1, -1),
_ => Vector2.One,
};
}