Compare commits

...

2 Commits

Author SHA1 Message Date
60b369fe27 use HAXE_PATH in makefile 2022-03-08 01:45:48 +01:00
1b9009d8e3 added Pos 2022-03-08 01:45:25 +01:00
2 changed files with 27 additions and 1 deletions

View File

@@ -18,7 +18,7 @@ debug: HAXE_FLAGS += -D webconsole --debug
debug: build debug: build
$(HAXE_PATH): $(shell find src -name '*.hx') $(HAXE_PATH): $(shell find src -name '*.hx')
haxe build.hxml $(HAXE_FLAGS) haxe build.hxml $(HAXE_FLAGS) --cmd "cp build/haxe.lua $(HAXE_PATH)"
$(MIN_PATH): $(POLYFILL_PATH) $(MIN_PATH): $(POLYFILL_PATH)
node minify.js $(POLYFILL_PATH) $@ node minify.js $(POLYFILL_PATH) $@

26
src/util/Pos.hx Normal file
View File

@@ -0,0 +1,26 @@
package util;
import util.Vec.Vec2;
@: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,
});
}
}