mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-18 19:41:54 +08:00
Reorganizing
This commit is contained in:
13
src/Static/Calc.bf
Normal file
13
src/Static/Calc.bf
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Calc
|
||||
{
|
||||
[Inline]
|
||||
static public float Approach(float value, float target, float maxDelta)
|
||||
{
|
||||
return value > target ? Math.Max(value - maxDelta, target) : Math.Min(value + maxDelta, target);
|
||||
}
|
||||
}
|
||||
}
|
16
src/Static/Draw.bf
Normal file
16
src/Static/Draw.bf
Normal file
@ -0,0 +1,16 @@
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Draw
|
||||
{
|
||||
static public void Rect(int x, int y, int w, int h, SDL2.SDL.Color color)
|
||||
{
|
||||
SDL2.SDL.SetRenderDrawColor(Game.mRenderer, color.r, color.g, color.b, color.a);
|
||||
SDL2.SDL.RenderFillRect(Game.mRenderer, &SDL2.SDL.Rect((int32)x, (int32)y, (int32)w, (int32)h));
|
||||
}
|
||||
|
||||
static public void Rect(Rect rect, SDL2.SDL.Color color)
|
||||
{
|
||||
Rect(rect.X, rect.Y, rect.Width, rect.Height, color);
|
||||
}
|
||||
}
|
||||
}
|
19
src/Static/Time.bf
Normal file
19
src/Static/Time.bf
Normal file
@ -0,0 +1,19 @@
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Time
|
||||
{
|
||||
static public float Elapsed;
|
||||
static public float PreviousElapsed;
|
||||
static public float Delta = 1 / 60f;
|
||||
|
||||
static public bool OnInterval(float interval, float offset = 0)
|
||||
{
|
||||
return (int)((Elapsed - offset) / interval) != (int)((PreviousElapsed - offset) / interval);
|
||||
}
|
||||
|
||||
static public bool BetweenInterval(float interval, float offset = 0)
|
||||
{
|
||||
return (Elapsed - offset) % (interval * 2) >= interval;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user