-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirection.py
More file actions
51 lines (47 loc) · 887 Bytes
/
direction.py
File metadata and controls
51 lines (47 loc) · 887 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#directions are set in stone
#a new object is created at each use though
#inheritance as interface is useless though thx to duck typing :/
#habits are tough
class constVec:
def __str__(self):
return "Vec"
def x(self):
return 0;
def y(self):
return 0;
def asTuple(self):
return (self.x(), self.y())
def addTo(self, tupleVec):
X, Y = tupleVec
X += self.x()
Y += self.y()
return (X, Y)
class right(constVec):
def __str__(self):
return "right"
def x(self):
return 1;
def y(self):
return 0;
class left(constVec):
def __str__(self):
return "left"
def x(self):
return -1;
def y(self):
return 0;
class up(constVec):
def __str__(self):
return "up"
def x(self):
return 0;
def y(self):
return -1;
class down(constVec):
def __str__(self):
return "down"
def x(self):
return 0;
def y(self):
return 1;
ALL = [ right(), left(), up(), down() ]