-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallClass.py
59 lines (46 loc) · 1.76 KB
/
wallClass.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
import turtle as t
from config import windowWidth, windowHigh
window = t.Screen()
window.addshape('block.gif')
class Walls:
wallsTab = []
wallSize = (2,2)
def __init__(self, pos):
self.wall = t.Turtle()
self.wall.shape("block.gif")
self.wall.color("#001a8f")
self.wall.penup()
self.wall.shapesize(stretch_len=Walls.wallSize[0], stretch_wid=Walls.wallSize[1])
self.wall.goto(pos[0], pos[1])
self.wall.width = 40
self.wall.height = 40
@staticmethod
def drawWalls():
for x in range(int((windowWidth/2 * -1) + Walls.wallSize[0]*10), int((windowWidth/2)), Walls.wallSize[0]*20):
Walls.wallsTab.append(Walls((x, 380)))
Walls.wallsTab.append(Walls((x, -380)))
for y in range(int((windowHigh/2 * -1) + Walls.wallSize[1]*10), int((windowHigh/2)), Walls.wallSize[1]*20):
Walls.wallsTab.append(Walls((380, y)))
Walls.wallsTab.append(Walls((-380, y)))
@staticmethod
def addWall(x, y):
Walls.wallsTab.append(Walls((int(round(x/10)*10), int(round(y/10)*10))))
@staticmethod
def deleteWall(x, y):
for wall in Walls.wallsTab:
if wall.wall.pos()[0] < x+30 and wall.wall.pos()[0] > x-30 and wall.wall.pos()[1] < y+30 and wall.wall.pos()[1] > y-30:
Walls.wallsTab.remove(wall)
wall.wall.hideturtle()
del wall
break
@staticmethod
def importWalls(walls):
for wall in walls:
Walls.addWall(wall[0], wall[1])
@staticmethod
def printAllWalls():
allWalls = []
for wall in Walls.wallsTab:
allWalls.append(wall.wall.pos())
print("\n\nWalls: \n")
print(allWalls)