Main.hx 450 B

12345678910111213141516171819202122
  1. @:forward(x, y)
  2. abstract Point({x:Float, y:Float}) {
  3. public inline function new(x:Float, y:Float) {
  4. this = {x: x, y: y};
  5. }
  6. @:op(A + B) inline function add(other:Point):Point {
  7. return new Point(this.x + 2 * other.x, this.y + 2 * other.y);
  8. }
  9. }
  10. class Player {
  11. public final position = new Point(0, 0);
  12. public function new() {}
  13. }
  14. class Main {
  15. static function main() {
  16. final player = new Player();
  17. player.position += new Point(1, 1);
  18. }
  19. }