diff options
| author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-10-26 12:52:34 +0200 |
|---|---|---|
| committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-10-26 12:52:34 +0200 |
| commit | 57f20a5ef761985b34817846d471a064b180e089 (patch) | |
| tree | 9d0029868b9e170bf07ffab9e0386b06b4189837 /Vec.py | |
| download | SnakePuzzle-57f20a5ef761985b34817846d471a064b180e089.tar.gz SnakePuzzle-57f20a5ef761985b34817846d471a064b180e089.zip | |
feat: implemented simple snake game
Diffstat (limited to 'Vec.py')
| -rw-r--r-- | Vec.py | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -0,0 +1,23 @@ + +class Vec2: + + x = 0 + y = 0 + + def __init__(self, x, y): + self.x = x + self.y = y + + def __add__(self, other): + return Vec2(self.x + other.x, self.y + other.y) + + def __eq__(self, other): + return (other != None) and (self.x == other.x) and (self.y == other.y) + + def neg(self): + return Vec2(-self.x, -self.y) + +right = Vec2(1, 0) +up = Vec2(0, -1) +left = Vec2(-1, 0) +down = Vec2(0, 1) |
