JumpThru movements

This commit is contained in:
Matt Thorson 2020-05-05 20:03:25 -07:00
parent bde9a51f9e
commit adad88ee83
4 changed files with 57 additions and 18 deletions

View File

@ -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;

View File

@ -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;

View File

@ -9,7 +9,16 @@ namespace Strawberry
Hitbox = Rect(0, 0, width, 6);
}
public override void Update()
{
base.Update();
MoveY(-10 * Time.Delta);
}
public override void MoveExactX(int amount)
{
if (Collidable)
{
let riders = GetRiders(scope List<Actor>);
@ -17,10 +26,36 @@ namespace Strawberry
for (var r in riders)
r.MoveExactX(amount);
}
else
X += amount;
}
public override void MoveExactY(int amount)
{
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)