From 1b9009d8e321280eb6ebc043a44fc39916029c30 Mon Sep 17 00:00:00 2001 From: Djeeberjr Date: Tue, 8 Mar 2022 01:45:25 +0100 Subject: [PATCH] added Pos --- src/util/Pos.hx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/util/Pos.hx 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, + }); + } +}