-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class.py
121 lines (104 loc) · 4.99 KB
/
Class.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
__author__ = 'moorerm'
import turtle
from Stack import Stack
class Turtle():
stack = Stack()
def __init__(self):
self.pacman = turtle.Turtle()
self.currentposX = 0
self.currentposY = 20
self.Y = Stack()
self.X = Stack()
def check_dots(self):
"""
post: stops the dots from being drown on certain positions
"""
a = [-140,-20,20,60,180,220,260] #list for Y values
for i in a: #loop to traverse through list
if self.currentposX == -200 and self.currentposY == i or self.currentposX == 200 and self.currentposY == i : #compares X nd Y values
self.X.pop() #pops top of list
self.Y.pop() #pops top of list
self.currentposX = self.X.top() #sets new top
self.currentposY = self.Y.top() #sets new top
self.pacman.goto(self.currentposX,self.currentposY) #gos to specific position
############### The rest of the code does the exact same thing except it has different values it compares
b = [-220,-180,-140,-100,-60,20,60,100,140,180]
for i in b:
if self.currentposX == -360 and self.currentposY == i or self.currentposX == 360 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
c = [-140]
for i in c:
if self.currentposX == -400 and self.currentposY == i or self.currentposX == 400 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
d = [-140]
for i in d:
if self.currentposX == -440 and self.currentposY == i or self.currentposX == 440 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
e = [-140,100]
for i in e:
if self.currentposX == -320 and self.currentposY == i or self.currentposX == 320 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
f = [-140,100]
for i in f:
if self.currentposX == -280 and self.currentposY == i or self.currentposX == 280 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
g = [-140,260]
for i in g:
if self.currentposX == -160 and self.currentposY == i or self.currentposX == 160 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
h = [-300,-260,-220,-140,260]
for i in h:
if self.currentposX == -120 and self.currentposY == i or self.currentposX == 120 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
j = [-60,100]
for i in j:
if self.currentposX == -80 and self.currentposY == i or self.currentposX == 80 and self.currentposY == i or self.currentposX == 0 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
k = [-260,-60,100]
for i in k:
if self.currentposX == -40 and self.currentposY == i or self.currentposX == 40 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)
l = [-260,-140,-100,-60,100,140,180]
for i in l:
if self.currentposX == 0 and self.currentposY == i:
self.X.pop()
self.Y.pop()
self.currentposX = self.X.top()
self.currentposY = self.Y.top()
self.pacman.goto(self.currentposX,self.currentposY)