summaryrefslogtreecommitdiff
path: root/Vec.py
blob: 9f22dd09828f52df88d623b00d1eec87dc49bcb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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)