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

60
src/Numerics/Point.bf Normal file
View File

@ -0,0 +1,60 @@
using System;
namespace Strawberry
{
public struct Point
{
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;
public this()
{
this = default;
}
public this(int x, int y)
{
X = x;
Y = y;
}
static public explicit operator Point(Vector a)
{
return Point((int)a.X, (int)a.Y);
}
static public bool operator==(Point a, Point b)
{
return a.X == b.X && a.Y == b.Y;
}
static public Point operator+(Point a, Point b)
{
return Point(a.X + b.X, a.Y + b.Y);
}
static public Point operator-(Point a, Point b)
{
return Point(a.X - b.X, a.Y - b.Y);
}
static public Point operator*(Point a, int b)
{
return Point(a.X * b, a.Y * b);
}
static public Point operator/(Point a, int b)
{
return Point(a.X / b, a.Y / b);
}
}
}