mirror of
				https://github.com/MaddyThorson/StrawberryBF.git
				synced 2025-11-04 01:41:33 +08:00 
			
		
		
		
	JumpThru movements
This commit is contained in:
		@ -4,12 +4,14 @@ namespace Strawberry
 | 
			
		||||
{
 | 
			
		||||
	public struct Point
 | 
			
		||||
	{
 | 
			
		||||
		static public readonly Point Right = Point(1, 0);
 | 
			
		||||
		static public readonly Point Left = Point(-1, 0);
 | 
			
		||||
		static public readonly Point Up = Point(0, -1);
 | 
			
		||||
		static public readonly Point Down = Point(0, 1);
 | 
			
		||||
		static public readonly Point Zero = Point(0, 0);
 | 
			
		||||
		static public readonly Point One = Point(1, 1);
 | 
			
		||||
		static public readonly Point Right = .(1, 0);
 | 
			
		||||
		static public readonly Point Left = .(-1, 0);
 | 
			
		||||
		static public readonly Point Up = .(0, -1);
 | 
			
		||||
		static public readonly Point Down = .(0, 1);
 | 
			
		||||
		static public readonly Point UnitX = .(1, 0);
 | 
			
		||||
		static public readonly Point UnitY = .(0, 1);
 | 
			
		||||
		static public readonly Point Zero = .(0, 0);
 | 
			
		||||
		static public readonly Point One = .(1, 1);
 | 
			
		||||
 | 
			
		||||
		public int X;
 | 
			
		||||
		public int Y;
 | 
			
		||||
@ -4,12 +4,14 @@ namespace Strawberry
 | 
			
		||||
{
 | 
			
		||||
	public struct Vector
 | 
			
		||||
	{
 | 
			
		||||
		static public readonly Vector Right = Vector(1, 0);
 | 
			
		||||
		static public readonly Vector Left = Vector(-1, 0);
 | 
			
		||||
		static public readonly Vector Up = Vector(0, -1);
 | 
			
		||||
		static public readonly Vector Down = Vector(0, 1);
 | 
			
		||||
		static public readonly Vector Zero = Vector(0, 0);
 | 
			
		||||
		static public readonly Vector One = Vector(1, 1);
 | 
			
		||||
		static public readonly Vector Right = .(1, 0);
 | 
			
		||||
		static public readonly Vector Left = .(-1, 0);
 | 
			
		||||
		static public readonly Vector Up = .(0, -1);
 | 
			
		||||
		static public readonly Vector Down = .(0, 1);
 | 
			
		||||
		static public readonly Vector UnitX = .(1, 0);
 | 
			
		||||
		static public readonly Vector UnitY = .(0, 1);
 | 
			
		||||
		static public readonly Vector Zero = .(0, 0);
 | 
			
		||||
		static public readonly Vector One = .(1, 1);
 | 
			
		||||
 | 
			
		||||
		public float X;
 | 
			
		||||
		public float Y;
 | 
			
		||||
@ -9,18 +9,53 @@ namespace Strawberry
 | 
			
		||||
			Hitbox = Rect(0, 0, width, 6);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void Update()
 | 
			
		||||
		{
 | 
			
		||||
			base.Update();
 | 
			
		||||
 | 
			
		||||
			MoveY(-10 * Time.Delta);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactX(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			let riders = GetRiders(scope List<Actor>);
 | 
			
		||||
 | 
			
		||||
			X += amount;
 | 
			
		||||
			for (var r in riders)
 | 
			
		||||
				r.MoveExactX(amount);
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>);
 | 
			
		||||
	
 | 
			
		||||
				X += amount;
 | 
			
		||||
				for (var r in riders)
 | 
			
		||||
					r.MoveExactX(amount);
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				X += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override void MoveExactY(int amount)
 | 
			
		||||
		{
 | 
			
		||||
			let riders = GetRiders(scope List<Actor>);
 | 
			
		||||
			if (Collidable)
 | 
			
		||||
			{
 | 
			
		||||
				let riders = GetRiders(scope List<Actor>);
 | 
			
		||||
 | 
			
		||||
				if (amount < 0)
 | 
			
		||||
				{
 | 
			
		||||
					for (var a in Scene.All<Actor>(scope List<Actor>))
 | 
			
		||||
						if (riders.Contains(a) || CheckOutside(a, Point.UnitY * amount))
 | 
			
		||||
							a.MoveExactY((Top + amount) - a.Bottom);
 | 
			
		||||
					Y += amount;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					Collidable = false;
 | 
			
		||||
 | 
			
		||||
					for (var a in riders)
 | 
			
		||||
						a.MoveExactY(amount);
 | 
			
		||||
 | 
			
		||||
					Collidable = true;
 | 
			
		||||
					Y += amount;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
				Y += amount;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		public override List<Actor> GetRiders(List<Actor> into)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user