mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-18 19:41:54 +08:00
Reorg
This commit is contained in:
26
src/Static/Calc.bf
Normal file
26
src/Static/Calc.bf
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static public void Log()
|
||||
{
|
||||
Debug.WriteLine("***");
|
||||
}
|
||||
|
||||
static public void Log<T>(T v)
|
||||
{
|
||||
String string = scope String;
|
||||
v.ToString(string);
|
||||
Debug.WriteLine(string);
|
||||
}
|
||||
}
|
||||
}
|
35
src/Static/Draw.bf
Normal file
35
src/Static/Draw.bf
Normal file
@ -0,0 +1,35 @@
|
||||
using SDL2;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Draw
|
||||
{
|
||||
static public void Rect(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
||||
SDL.RenderFillRect(Game.Renderer, &SDL.Rect((int32)x, (int32)y, (int32)w, (int32)h));
|
||||
}
|
||||
|
||||
static public void Rect(Rect rect, Color color)
|
||||
{
|
||||
Rect(rect.X, rect.Y, rect.Width, rect.Height, color);
|
||||
}
|
||||
|
||||
static public void HollowRect(int x, int y, int w, int h, Color color)
|
||||
{
|
||||
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
||||
SDL.RenderDrawRect(Game.Renderer, &SDL.Rect((int32)x, (int32)y, (int32)w, (int32)h));
|
||||
}
|
||||
|
||||
static public void HollowRect(Rect rect, Color color)
|
||||
{
|
||||
HollowRect(rect.X, rect.Y, rect.Width, rect.Height, color);
|
||||
}
|
||||
|
||||
static public void Line(Point from, Point to, Color color)
|
||||
{
|
||||
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
||||
SDL.RenderDrawLine(Game.Renderer, (int32)from.X, (int32)from.Y, (int32)to.X, (int32)to.Y);
|
||||
}
|
||||
}
|
||||
}
|
23
src/Static/Time.bf
Normal file
23
src/Static/Time.bf
Normal file
@ -0,0 +1,23 @@
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Time
|
||||
{
|
||||
static public float Elapsed;
|
||||
static public float PreviousElapsed;
|
||||
static public float Rate = 1f;
|
||||
static public float Freeze;
|
||||
|
||||
static public float RawDelta => (1 / 60f);
|
||||
static public float Delta => RawDelta * Rate;
|
||||
|
||||
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