mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-07-18 19:41:54 +08:00
Color fixes. Draw.Circle. JSON.Enum. OnCollide leak fix
This commit is contained in:
@ -5,6 +5,14 @@ namespace Strawberry
|
||||
{
|
||||
static public class Calc
|
||||
{
|
||||
public const float Circle = Math.PI_f * 2;
|
||||
public const float Right = 0;
|
||||
public const float Left = Math.PI_f;
|
||||
public const float Up = Math.PI_f * -0.5f;
|
||||
public const float Down = Math.PI_f * 0.5f;
|
||||
public const float DegToRad = Math.PI_f / 180f;
|
||||
public const float RadToDeg = 180f / Math.PI_f;
|
||||
|
||||
[Inline]
|
||||
static public bool BitCheck(int bits, int pos)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SDL2;
|
||||
using System;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
@ -37,6 +38,27 @@ namespace Strawberry
|
||||
SDL.RenderDrawLine(Game.Renderer, (int32)fromn.X, (int32)fromn.Y, (int32)ton.X, (int32)ton.Y);
|
||||
}
|
||||
|
||||
static public void Circle(Point at, float radius, Color color, int steps = 16)
|
||||
{
|
||||
let add = at - Camera;
|
||||
|
||||
SDL.Point[] points = scope SDL.Point[steps + 1];
|
||||
points[0] = SDL.Point((int32)(radius + add.X), (int32)add.Y);
|
||||
points[steps] = points[0];
|
||||
float slice = Calc.Circle / steps;
|
||||
|
||||
for (int i = 1; i < steps; i++)
|
||||
{
|
||||
points[i] = SDL.Point(
|
||||
(int32)(Math.Round(Math.Cos(slice * i) * radius) + add.X),
|
||||
(int32)(Math.Round(Math.Sin(slice * i) * radius) + add.Y)
|
||||
);
|
||||
}
|
||||
|
||||
SDL.SetRenderDrawColor(Game.Renderer, color.R, color.G, color.B, color.A);
|
||||
SDL.RenderDrawLines(Game.Renderer, &points[0], (int32)steps + 1);
|
||||
}
|
||||
|
||||
static public void Sprite(Sprite sprite, int frame, Point position)
|
||||
{
|
||||
SDL.Rect src = Strawberry.Rect(0, 0, sprite.Width, sprite.Height);
|
||||
|
Reference in New Issue
Block a user