-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPLAAATOMAKER.py
341 lines (283 loc) · 13.7 KB
/
SPLAAATOMAKER.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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# ==================================================================================== IMPORTS ========================================================================= #
from upemtk import *
from math import *
from os import path
# =============================================================================== NOS MODULES A NOUS ================================================================== #
# ==================================================================================== FONCTIONS ====================================================================== #
# ============================================================================== VARIABLES ================================================================================== #
#Fenêtres
hauteurFenetre = 1030
largeurFenetre = 1920
policevar = 'Franklin Gothic Medium Cond'
TAI = 45
# ================================================================================== CODE PRINCIPAL ========================================================================== #
def SPLAATOMAKER(independance):
#Zone de jeu
rectangle(0,0,1220,1029,'black')
#Zone des paramètres
rectangle(1221,0,1919,1029,'black','honeydew3')
#Paramètres
rectangle(1240,20,1900,150,'red','white',10,'boitedialogue')
rectangle(1360,750,1780,850,'black','coral2',tag='Sauvegarder')
texte(1570,800,"SAUVEGARDER", "black", "center",police=policevar)
rectangle(1360,875,1780,975,'black','DeepSkyBlue3',tag='Quitter')
texte(1570,925,"QUITTER", "black", "center",police=policevar)
rectangle(1240,20,1900,150,'black','white',10,tag='fen')
rectangle(1458,180,1548,270,'black')
rectangle(1478,200,1528,250,'black','black')
#1503
rectangle(1590,180,1680,270,'black')
cercle(1637,225,30,'black','black')
rectangle(1240,301,1364,425)
texte(1302,363,"0",ancrage='center',taille=TAI)
rectangle(1374,301,1498,425)
texte(1436,363,"1",ancrage='center',taille=TAI)
rectangle(1508,301,1632,425)
texte(1570,363,"2",ancrage='center',taille=TAI)
rectangle(1642,301,1766,425)
texte(1704,363,"3",ancrage='center',taille=TAI)
rectangle(1776,301,1900,425)
texte(1838,363,"4",ancrage='center',taille=TAI)
rectangle(1240,435,1364,559)
texte(1302,497,"5",ancrage='center',taille=TAI)
rectangle(1374,435,1498,559)
texte(1436,497,"6",ancrage='center',taille=TAI)
rectangle(1508,435,1632,559)
texte(1570,497,"7",ancrage='center',taille=TAI)
rectangle(1642,435,1766,559)
texte(1704,497,"8",ancrage='center',taille=TAI)
rectangle(1776,435,1900,559)
texte(1838,497,"9",ancrage='center',taille=TAI)
rectangle(1240,580,1565,640)
texte(1402,610,"Valider",ancrage='center')
rectangle(1575,580,1900,640)
texte(1737,610,"Effacer",ancrage='center')
# =========================================================================================================================================================================== #
# == JEU == #
# =========================================================================================================================================================================== #
def choix_rayon():
rayon = None
chrrayon = ''
while rayon is None :
efface('choixTB')
texte(1570,66,'Choix taille boules :',ancrage='center',tag='ctbr')
texte(1480,100,"Taille :",ancrage='center',tag='choixTB')
texte(1600,100,chrrayon,ancrage='center',tag='choixTB')
#Truc pr faire des événement de la doc
evenement = donne_evenement()
type_ev = type_evenement(evenement) #type = touche ou clic
if type_ev == 'Touche':
nom_touche = touche(evenement)
if nom_touche == 'Return':
if 10 <= int(chrrayon):
rayon = int(chrrayon)
return rayon
else :
rectangle(1240,20,1900,150,'red',remplissage='white',epaisseur=10,tag='boitealerte')
texte(1570,80,'LA TAILLE DOIT ETRE CONTENUE ENTRE 10 ET 100',ancrage='center',couleur='red',tag='alerte',taille=18)
attente_clic()
efface('alerte')
efface('boitealerte')
if type_ev == "ClicDroit": #Dire le type de evenement (touche ou clic)
x = int(clic_x(evenement)) #On note les co de x
y = int(clic_y(evenement)) #On note les co de y
print(calcul_effacer(x,y,lstobs))
if type_ev == "ClicGauche": #Dire le type de evenement (touche ou clic)
x = int(clic_x(evenement)) #On note les co de x
y = int(clic_y(evenement)) #On note les co de y
#print((clic_x(evenement)),(clic_y(evenement)))
if 1240<x<1364 and 301<y<425:
chrrayon += '0'
if 1374<x<1498 and 301<y<425:
chrrayon += '1'
if 1508<x<1632 and 301<y<425:
chrrayon += '2'
if 1642<x<1766 and 301<y<425:
chrrayon += '3'
if 1776<x<1900 and 301<y<425:
chrrayon += '4'
if 1240<x<1364 and 435<y<559:
chrrayon += '5'
if 1374<x<1498 and 435<y<559:
chrrayon += '6'
if 1508<x<1632 and 435<y<559:
chrrayon += '7'
if 1642<x<1766 and 435<y<559:
chrrayon += '8'
if 1776<x<1900 and 435<y<559:
chrrayon += '9'
if 1575<x<1900 and 580<y<640:
chrrayon = ''
if 1360<x<1780 and 875<y<975:
ferme_fenetre()
quit()
if 1360<x<1780 and 750<y<850:
fin = True
break
if 1240<x<1565 and 580<y<640:
if 10 <= int(chrrayon):
rayon = int(chrrayon)
return rayon
else :
rectangle(1240,20,1900,150,'red',remplissage='white',epaisseur=10,tag='boitealerte')
texte(1570,80,'LA TAILLE DOIT ETRE CONTENUE ENTRE 10 ET 100',ancrage='center',couleur='red',tag='alerte',taille=18)
attente_clic()
efface('alerte')
efface('boitealerte')
mise_a_jour()
def pose_ronds (Ox, Oy, rayon,tour) :
if Ox + rayon > 1220 :
fautecercle(Ox, Oy, rayon, "FAUTE : Zone de jeu")
return
else :
cercle(Ox,Oy,rayon,'black','black',tag='black'+str(tour))
lstobs.append(['RON',Ox,Oy,rayon,'black'+str(tour)])
mise_a_jour()
def pose_carre(Ox,Oy,rayon,tour):
if Ox + rayon > 1220 :
fautecarre(Ox, Oy, rayon, "FAUTE : Zone de jeu")
return
else :
rectangle(Ox,Oy,Ox+rayon,Oy+rayon,'black','black',tag='black'+str(tour))
lstobs.append(['CAR',Ox,Oy,Ox+rayon,Oy+rayon,rayon,'black'+str(tour)])
mise_a_jour()
def calcul_effacer(x,y,lst):
for i in range(len(lst)):
if lst[i][0] == 'RON' :
if sqrt((lst[i][1]-x)**2 + (lst[i][2]-y)**2) < lst[i][2] :
efface(lst[i][4])
lst.remove(lst[i])
return
elif lst[i][0] == 'CAR' :
print(x,y)
if lst[i][1] <= x <= lst[i][3] and lst[i][2] <= y <= lst[i][4] :
print(lst[i][6])
efface(lst[i][6])
lst.remove(lst[i])
return
def clicOxOy():
Ox = None
Oy = None
pose = False
debuttimer = None
while Ox == None :
evenement = donne_evenement()
type_ev = type_evenement(evenement)
if type_ev == 'ClicGauche' :
Oy = clic_y(evenement)
Ox = clic_x(evenement)
return Ox,Oy
mise_a_jour()
def fautecercle (Ox,Oy,rayon, text):
if Ox != None :
cercle(Ox,Oy,rayon,'red',tag='Faute')
efface('tour')
rectangle(1240,20,1900,150,'red',remplissage='white',epaisseur=10,tag='Faute')
texte(1570,60,text,'red','center','Franklin Gothic Medium Cond',30,'Faute')
attente_clic()
efface('Faute')
return
def fautecarre (Ox,Oy,rayon,text):
if Ox != None :
rectangle(Ox,Oy,Ox+rayon,Oy+rayon,'red',tag='Faute')
efface('tour')
rectangle(1240,20,1900,150,'red',remplissage='white',epaisseur=10,tag='Faute')
texte(1570,60,text,'red','center','Franklin Gothic Medium Cond',30,'Faute')
attente_clic()
efface('Faute')
return
def choix_forme():
forme = None
while forme == None :
evenement = donne_evenement()
type_ev = type_evenement(evenement)
if type_ev == 'ClicGauche' :
y = clic_y(evenement)
x = clic_x(evenement)
if 1600<x<1680 and 180<y<270:
forme = 'rond'
return forme
if 1458<x<1548 and 180<y<270:
forme = 'carre'
return forme
mise_a_jour()
def clavier():
valider = False
nom =''
#================QUITTER ==================================================
rectangle(1840,20,1900,80,'black','DeepSkyBlue3',4)
texte(1870,50,"X",'black','center',taille=45)
#================LOGO =====================================================
image(990,150,path.join('.','icones','LOGOMAKER.png'),ancrage='center')
#================INFORMATIONS =============================================
texte(990,350,"ATTENTION : Si vous appelez votre fichier par le nom d'un fichier déjà existant, le fichier précédent sera écrasé",'black','center')
texte(990,410,'Seules les touches minuscules et "_" sont comptabilisées','black','center')
#================INPUT ====================================================
rectangle(490,500,1490,600,'black','white',4)
#================VALIDER ==================================================
rectangle(790,700,1190,800,'black','coral2',4)
texte(990,750,'VALIDER','black','center',taille=24)
while valider != True :
texte(990,550,nom,ancrage='center',tag='nom')
#Truc pr faire des événement de la doc
evenement = donne_evenement()
type_ev = type_evenement(evenement) #type = touche ou clic
if type_ev == "ClicGauche": #Dire le type de evenement (touche ou clic)
x = int(clic_x(evenement)) #On note les co de x
y = int(clic_y(evenement)) #On note les co de y
if 1840<x<1900 and 20<y<80 :
ferme_fenetre()
if 790<x<1190 and 700<y<800:
return nom
else :
continue
if type_ev == 'Touche':
nom_touche = touche(evenement)
if nom_touche == 'underscore' :
nom += "_"
if nom_touche == 'Return':
valider = True
return nom
if nom_touche == 'Delete':
nom = nom[:-1]
if nom_touche == 'BackSpace':
nom = nom[:-1]
else :
nom += nom_touche
efface('nom')
mise_a_jour()
#=========================================================== VARIABLES ==========================================================
fin = False
lstobs = []
tour = 0
#=========================================================== CODE PRINCIPAL ==========================================================
while fin != True :
num_tour = str(tour + 1)
rayon = choix_rayon()
texte(1570,125,'CHOISIR LA FORME',ancrage='center',couleur='black',tag='ATTENTE',taille=15)
if rayon is None :
fin = True
else :
forme = choix_forme()
efface('ATTENTE')
texte(1570,125,'VEUILLEZ PLACER VOTRE FORME',ancrage='center',couleur='black',tag='ATTENTE',taille=15)
Ox, Oy = clicOxOy()
efface('ATTENTE')
if forme == 'rond' :
pose_ronds(Ox, Oy,rayon,num_tour)
elif forme == 'carre' :
pose_carre(Ox,Oy,rayon,num_tour)
tour +=1
efface_tout()
nom = clavier()
nom = str(nom)+".txt"
lien = path.join(".","saves_obstacles",nom)
with open(lien,'x') as fichier :
fichier.write(str(lstobs))
if independance == False :
return nom
if __name__ == "__main__" :
cree_fenetre(largeurFenetre,hauteurFenetre)
SPLAATOMAKER(True)
ferme_fenetre()
quit()