-
-
Save ibilon/414b820c6bffe36139385d9dced3f929 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@:forward(x, y) | |
abstract Point({x:Float, y:Float}) { | |
public inline function new(x:Float, y:Float) { | |
this = {x: x, y: y}; | |
} | |
@:op(A + B) inline function add(other:Point):Point { | |
return new Point(this.x + other.x, this.y + other.y); | |
} | |
@:op(A += B) inline function set_add(other:Point):Void { | |
this.x += other.x; | |
this.y += other.y; | |
} | |
} | |
class Player { | |
public final position = new Point(0, 0); | |
public function new() {} | |
} | |
class Main { | |
static function main() { | |
final player = new Player(); | |
player.position += new Point(1, 1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment