Reorganizing

This commit is contained in:
Matt Thorson
2020-05-05 18:51:27 -07:00
parent 9374086e97
commit 409a82d6b8
9 changed files with 85 additions and 24 deletions

View File

@ -7,15 +7,15 @@ namespace Strawberry
{
private Vector remainder;
public this(int x, int y)
: base(x, y)
public this(Point position)
: base(position)
{
}
public bool GroundCheck(int distance = 1)
{
return Check<Solid>(.(0, distance));
return Check<Solid>(.(0, distance)) || CheckOutside<JumpThru>(.(0, distance));
}
public virtual bool IsRiding(Solid solid)
@ -23,9 +23,14 @@ namespace Strawberry
return Check(solid, .(0, 1));
}
public virtual bool IsRiding(JumpThru jumpThru)
{
return CheckOutside(jumpThru, .(0, 1));
}
public virtual void Squish()
{
Scene.Remove(this);
RemoveSelf();
}
public bool MoveX(float amount, Action<Collision> onCollide = null)
@ -90,7 +95,10 @@ namespace Strawberry
int sign = Math.Sign(amount);
while (move != 0)
{
let hit = First<Solid>(.(0, sign));
Geometry hit = First<Solid>(.(0, sign));
if (hit == null && sign == 1)
hit = FirstOutside<JumpThru>(.(0, sign));
if (hit != null)
{
ZeroRemainderY();

View File

@ -7,8 +7,8 @@ namespace Strawberry
{
private Vector remainder;
public this(int x, int y)
: base(x, y)
public this(Point position)
: base(position)
{
}

39
src/Physics/JumpThru.bf Normal file
View File

@ -0,0 +1,39 @@
using System.Collections;
namespace Strawberry
{
public class JumpThru : Geometry
{
public this(Point position, int width)
: base(position)
{
Hitbox = Rect(0, 0, width, 6);
}
public override void MoveExactX(int amount)
{
let riders = GetRiders(scope List<Actor>);
X += amount;
for (var r in riders)
r.MoveExactX(amount);
}
public override void MoveExactY(int amount)
{
let riders = GetRiders(scope List<Actor>);
}
public override List<Actor> GetRiders(List<Actor> into)
{
for (var a in Scene.All<Actor>(scope List<Actor>))
if (a.IsRiding(this))
into.Add(a);
return into;
}
public override void Draw()
{
DrawHitbox(.(255, 255, 255, 255));
}
}
}

View File

@ -4,17 +4,12 @@ namespace Strawberry
{
public class Solid : Geometry
{
public this(int x, int y, Rect hitbox)
: base(x, y)
public this(Point position, Rect hitbox)
: base(position)
{
Hitbox = hitbox;
}
public override void Draw()
{
DrawHitbox(.(255, 255, 255, 255));
}
public override List<Actor> GetRiders(List<Actor> into)
{
for (var a in Scene.All<Actor>(scope List<Actor>))
@ -38,5 +33,10 @@ namespace Strawberry
}
}
public override void Draw()
{
DrawHitbox(.(255, 255, 255, 255));
}
}
}