From ebd57e4bc6972a79a5de1c52646f75ca15abdaee Mon Sep 17 00:00:00 2001 From: Vladimir Olteanu Date: Thu, 29 Apr 2021 15:17:12 +0300 Subject: [PATCH] Operators for Point: +, -, +=, -= (#1739) --- Source/engine.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Source/engine.h b/Source/engine.h index e39dfb5a8..33afa7ecc 100644 --- a/Source/engine.h +++ b/Source/engine.h @@ -60,6 +60,32 @@ enum direction : uint8_t { struct Point { int x; int y; + + Point &operator +=(const Point &other) + { + x += other.x; + y += other.y; + return *this; + } + + Point &operator -=(const Point &other) + { + x -= other.x; + y -= other.y; + return *this; + } + + friend Point operator +(Point a, const Point &b) + { + a += b; + return a; + } + + friend Point operator -(Point a, const Point &b) + { + a -= b; + return a; + } }; struct ActorPosition {