-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapSystem.py
71 lines (55 loc) · 2.04 KB
/
MapSystem.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
import random
from graphics import *
win = GraphWin("My Game", 500, 500)
win.setBackground('black')
#initializez matricea elementelor cu 0
Mapa = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]]
culori = ['black', 'red', 'cyan', 'yellow', 'green', 'orange']
forme = ["forme/red.png", "forme/cyan.png", "forme/yellow.png", "forme/green.png", "forme/purple.png"]
sizeX = 8
sizeY = 7
#se populeaza matricea dupa numarul de elemente(level of dificulty) intr-un mod complet aleatoriu(random)
def matrix(level):
for i in range(0, 8):
for j in range(0, 7):
Mapa[i][j] = random.randint(1, level + 1)
def getGraph():
return win
def paintBackground():
gameBackground = Image(Point(250, 250), "forme/piramide.gif")
gameBackground.draw(win)
#se creaza tabela de joc si cu tabul pentru viata , level si score
def paintGameFrame():
setBlackBackground(73, 23,427, 427)
setBlackBackground(0, 440,500, 500)
def setBlackBackground(x1,y1,x2,y2):
background = Rectangle(Point(x1, y1), Point(x2, y2))
background.setFill('black')
background.draw(win)
def setWhiteText(x,y,theText):
text = Text(Point(x, y), theText)
text.setTextColor('white')
text.draw(win)
# se populeaza tabela de joc cu elementele din matricea jocului
def paintMap():
for j in range(0, sizeY):
for i in range(0, sizeX):
formia = Mapa[i][j] - 1
if formia > -1:
cir = Image(Point(j * 50 + 100, i * 50 + 50), forme[Mapa[i][j] - 1])
cir.draw(win)
else:
setBlackBackground(j * 50 + 75, i * 50 + 25, j * 50 + 125, i * 50 + 75)
def GameStillOn():
for i in Mapa:
for j in i:
if j != 0:
return True
return False
def exitGame():
win.close()
def paint():
paintBackground()
paintGameFrame()
paintMap()