mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-11-04 01:41:33 +08:00 
			
		
		
		
	Color fixes. Draw.Circle. JSON.Enum. OnCollide leak fix
This commit is contained in:
		@ -12,6 +12,11 @@ namespace Strawberry
 | 
			
		||||
			Action = action;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public ~this()
 | 
			
		||||
		{
 | 
			
		||||
			delete Action;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Started()
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,13 @@ namespace Strawberry
 | 
			
		||||
			
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public this(Action onComplete, bool destroyOnComplete = false)
 | 
			
		||||
			: base(false, false)
 | 
			
		||||
		{
 | 
			
		||||
			OnComplete = onComplete;
 | 
			
		||||
			RemoveOnComplete = destroyOnComplete;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public this(float value, Action onComplete, bool destroyOnComplete = false)
 | 
			
		||||
			: base(false, false)
 | 
			
		||||
		{
 | 
			
		||||
 | 
			
		||||
@ -20,6 +20,11 @@ namespace Strawberry
 | 
			
		||||
 | 
			
		||||
		public int Int => (int)Number;
 | 
			
		||||
		public char8 Char => String[0];
 | 
			
		||||
		public T Enum<T>() where T : Enum
 | 
			
		||||
		{
 | 
			
		||||
			Runtime.Assert(Type == .String);
 | 
			
		||||
			return T.Parse<T>(String, true);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		private List<JSON> array;
 | 
			
		||||
		private Dictionary<String, JSON> children;
 | 
			
		||||
 | 
			
		||||
@ -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);
 | 
			
		||||
 | 
			
		||||
@ -10,9 +10,9 @@ namespace Strawberry
 | 
			
		||||
		static public readonly Color Red 			= 0xFF0000FF;
 | 
			
		||||
		static public readonly Color Green 			= 0x00FF00FF;
 | 
			
		||||
		static public readonly Color Blue 			= 0x0000FFFF;
 | 
			
		||||
		static public readonly Color Cyan 			= 0xFF00FFFF;
 | 
			
		||||
		static public readonly Color Magenta 		= 0xFFFF00FF;
 | 
			
		||||
		static public readonly Color Yellow 		= 0x00FFFFFF;
 | 
			
		||||
		static public readonly Color Cyan 			= 0x00FFFFFF;
 | 
			
		||||
		static public readonly Color Magenta 		= 0xFF00FFFF;
 | 
			
		||||
		static public readonly Color Yellow 		= 0xFFFF00FF;
 | 
			
		||||
		static public readonly Color DarkGray		= 0x3F3F3FFF;
 | 
			
		||||
		static public readonly Color Gray			= 0x7F7F7FFF;
 | 
			
		||||
		static public readonly Color LightGray		= 0xBFBFBFFF;
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user