blob: a6e0dcda866206f49cb4749b7d448ecf6138d7d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
from __future__ import annotations
class Vec2:
def __init__(self, x: int, y: int) -> None:
self.x = x
self.y = y
def __add__(self, other: 'Vec2') -> 'Vec2':
return Vec2(self.x + other.x, self.y + other.y)
def __eq__(self, other: object) -> bool:
match other:
case Vec2(): return self.x == other.x and self.y == other.y
case _: return False
def neg(self) -> 'Vec2':
return Vec2(-self.x, -self.y)
def toString(self) -> str:
return f"({self.x}, {self.y})"
right: Vec2 = Vec2(1, 0)
up: Vec2 = Vec2(0, -1)
left: Vec2 = Vec2(-1, 0)
down: Vec2 = Vec2(0, 1)
|