2022-12-19 20:06:23 +00:00
|
|
|
package lib;
|
2022-03-08 00:45:25 +00:00
|
|
|
|
2022-12-19 20:06:23 +00:00
|
|
|
import lib.Vec.Vec2;
|
2022-03-08 00:45:25 +00:00
|
|
|
|
2022-03-08 12:33:40 +00:00
|
|
|
/**
|
|
|
|
Reporesents a Point in a 2D `Int` System.
|
|
|
|
Basicly a wrapper for Vec2<Int> with some extra functions.
|
|
|
|
**/
|
2022-03-08 00:45:25 +00:00
|
|
|
@:forward(x,y)
|
|
|
|
abstract Pos(Vec2<Int>) from Vec2<Int> to Vec2<Int>{
|
|
|
|
inline public function new(i:Vec2<Int>) {
|
|
|
|
this = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A + B)
|
|
|
|
public function add(rhs: Vec2<Int>):Pos {
|
|
|
|
return new Pos({
|
|
|
|
y: this.y + rhs.y,
|
|
|
|
x: this.x + rhs.x,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(A - B)
|
|
|
|
public function sub(rhs: Vec2<Int>):Pos {
|
|
|
|
return new Pos({
|
|
|
|
y: this.y - rhs.y,
|
|
|
|
x: this.x - rhs.x,
|
|
|
|
});
|
|
|
|
}
|
2022-04-26 17:42:50 +00:00
|
|
|
|
|
|
|
@:op(A * B)
|
|
|
|
public function multiply(rhs: Vec2<Int>): Pos {
|
|
|
|
return new Pos({
|
|
|
|
y: this.y * rhs.y,
|
|
|
|
x: this.x * rhs.x,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@:op(-A)
|
|
|
|
public function negate(): Pos {
|
|
|
|
return new Pos({
|
|
|
|
y: -this.y,
|
|
|
|
x: -this.x,
|
|
|
|
});
|
|
|
|
}
|
2022-03-08 00:45:25 +00:00
|
|
|
}
|