diff --git a/src/util/Pos.hx b/src/util/Pos.hx new file mode 100644 index 0000000..5d145e9 --- /dev/null +++ b/src/util/Pos.hx @@ -0,0 +1,26 @@ +package util; + +import util.Vec.Vec2; + +@:forward(x,y) +abstract Pos(Vec2) from Vec2 to Vec2{ + inline public function new(i:Vec2) { + this = i; + } + + @:op(A + B) + public function add(rhs: Vec2):Pos { + return new Pos({ + y: this.y + rhs.y, + x: this.x + rhs.x, + }); + } + + @:op(A - B) + public function sub(rhs: Vec2):Pos { + return new Pos({ + y: this.y - rhs.y, + x: this.x - rhs.x, + }); + } +}