Bonjour,
J'ai un problème de list index out of range ligne 937. Je pense que c'est parce-que vu "CoorAcrA[g] et CoorAcrA[h]" je les supprimes car 2 dinos sont allés l'un sur l'autre alors je les supprime pour remplacer par une carcasse et donc ensuite dans le for j in ListeAcr les dinos ont disparus donc je ne peut plus les prendre. J'ai donc essayé de faire des break pour si des dinos sont supprimé on recommence la boucle avec les dinos en moi s mais ça ne marche toujours pas. Merci de votre aide




Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
#############################
#                           #
#        Importations :     #
#                           #
#############################
 
#Tkinter 3.4.3
from tkinter import *
from random import randrange
from random import *
from math import *
from tkinter.filedialog import *
#message=question yesno
from tkinter.messagebox import *
 
#############################
#                           #
#        Fonctions :        #
#                           #
#############################
 
def drawline():
    global x1,x2,y1
    while x1<510:
        can.create_line(x1,y1,x2,0,width=2,fill='white')
 
        x1=x1+30
        x2=x2+30
def drawline2():
    global y3,y4,x3
    while y3<510:
        can.create_line(x3,y3,0,y4,width=2,fill='white')
 
        y3=y3+30
        y4=y4+30
def STPASK():
    global STP
    global x
    global y
    global a
    global b
    global CoorAcrA
    global CoorAcrB
    global CoorCarA
    global CoorCarB
    if askyesno('STP','Voulez-vous utiliser votre stp?'):
        if STP<3:
            xx=x//30
            yy=y//30
            yyyy=Tabl[yy]
            yyyy.append(xx)
            yyyy.sort()
            Tabl[yy]=yyyy
            y=randint(0,16)
            xtabl=Tabl[y]
            le=len(xtabl)
            while (le==0):
                y=randint(0,16)
                xtabl=Tabl[y]
                le=len(xtabl)
            i=randint(0,le-1)
            x=xtabl[i]
            yyy=Tabl[y]
            yyy.remove(x)
            Tabl[y]=yyy
            x=x*30
            y=y*30
            can.coords(Per,x,y)
            STP=0
        else:
            xx=x//30
            yy=y//30
            yyyy=Tabl[yy]
            yyyy.append(xx)
            yyyy.sort()
            Tabl[yy]=yyyy
            y=randint(0,16)
            xtabl=Tabl[y]
            le=len(xtabl)
            while (le==0):
                y=randint(0,16)
                xtabl=Tabl[y]
                le=len(xtabl)
            i=randint(0,le-1)
            x=xtabl[i]
            yyy=Tabl[y]
            yyy.remove(x)
            Tabl[y]=yyy
            x=x*30
            y=y*30
            can.coords(Per,x,y)
            STP=0
 
            ################################# a faire stp sur
 
            #xx=x//30
            #yy=y//30
            #yyyy=Tabl[yy]
            #yyyy.append(xx)
            #yyyy.sort()
            #Tabl[yy]=yyyy
 
            #xtabl=Tabl[y]
            #le=len(xtabl)
            #while (le==0):
                #y=randint(0,16)
                #xtabl=Tabl[y]
                #le=len(xtabl)
            #i=randint(0,le-1)
            #x=xtabl[i]
            #yyy=Tabl[y]
            #yyy.remove(x)
            #Tabl[y]=yyy
 
            #xx=x//30
            #yy=y//30
            #yyyy=SurTabl[yy]
            #yyyy.append(xx)
            #yyyy.sort()
            #SurTabl[yy]=yyyy
 
            #y=randint(0,16)
            #xtabl=SurTabl[y]
            #le=len(xtabl)
            #while (le==0):
                #y=randint(0,16)
                #xtabl=SurTabl[y]
                #le=len(xtabl)
            #i=randint(0,le-1)
            #x=xtabl[i]
            #yyy=SurTabl[y]
            #yyy.remove(x)
            #SurTabl[y]=yyy
 
            #x=x*30
            #y=y*30
            #can.coords(Per,x,y)
            #STP=0
 
    else:
        if askyesno('Deplacement/Recharger', 'Voulez-vous recharger votre STP sinon vous déplacer?'):
            STP+=1
            showinfo('Votre stp est maintenant de:', STP)
        else:
            showinfo('A votre tour',"Veuillez bouger avec les boutons qui vont s'afficher.")
            root = Tk()
            app=Application(master=root)
            app.mainloop()
            root.destroy()
 
def DptAcro():
    global x
    global y
    global Tabl
    global ListeAcr
    global CoorAcrA
    global CoorAcrB
    for i in range (len(ListeAcr)):
        a=CoorAcrA[i]*30
        b=CoorAcrB[i]*30
        dx=x-a
        dy=y-b
        for f in range (0,1):
            if dx==0:
                if dy>0:
                    angle=0
                if dy<0:
                    angle=180
                if dy==0:
                    angle=360
            elif dy==0:
                if dx>0:
                    angle=270
                if dx<0:
                    angle=90
            else:
                dxy=dy/dx
                rad=atan(dxy)
                angle=rad*57.295779513082
                if dy<0:
                    if dx<0:
                        angle+=90
                    if dx>0:
                        angle+=270
                if dy>0:
                    if dx<0:
                        angle+=90
                    if dx>0:
                        angle+=270
        if (0<=angle<=22.5) or (360>=angle>337.5):
            #bas
            #aa=a//30
            #bb=b//30
            #bsur=SurTabl[bb]
            #bsur.append(aa)
            #bsur.sort()
            #SurTabl[bb]=bsur
            ##################################### a mettre partout et bbsur.remove(aa) ValueError: list.remove(x): x not in list
            b=b+30
            CoorAcrB[i]=CoorAcrB[i]+1
            can.coords(ListeAcr[i],a,b)
            #bb=b//30
 
            #bbsur=SurTabl[bb]
            #bbsur.remove(aa)
            #SurTabl[bb]=bbsur
 
        if (22.5<angle<=67.5):
            #basgauche
            a=a-30
            b=b+30
            CoorAcrA[i]=CoorAcrA[i]-1
            CoorAcrB[i]=CoorAcrB[i]+1
            can.coords(ListeAcr[i],a,b)
        if (67.5<angle<=112.5):
            #gauche
            a=a-30
            CoorAcrA[i]=CoorAcrA[i]-1
            can.coords(ListeAcr[i],a,b)
        if (112.5<angle<=157.5):
            #hautgauche
            a=a-30
            b=b-30
            CoorAcrA[i]=CoorAcrA[i]-1
            CoorAcrB[i]=CoorAcrB[i]-1
            can.coords(ListeAcr[i],a,b)
        if (157.5<angle<=202.5):
            #haut
            b=b-30
            CoorAcrB[i]=CoorAcrB[i]-1
            can.coords(ListeAcr[i],a,b)
        if (202.5<angle<=247.5):
            #hautdroite
            a=a+30
            b=b-30
            CoorAcrA[i]=CoorAcrA[i]+1
            CoorAcrB[i]=CoorAcrB[i]-1
            can.coords(ListeAcr[i],a,b)
        if (247.5<angle<=292.5):
            #droite
            a=a+30
            CoorAcrA[i]=CoorAcrA[i]+1
            can.coords(ListeAcr[i],a,b)
        if (292.5<angle<=337.5):
            #basdroite
            a=a+30
            b=b+30
            CoorAcrA[i]=CoorAcrA[i]+1
            CoorAcrB[i]=CoorAcrB[i]+1
            can.coords(ListeAcr[i],a,b)
 
def DptCarno():
    global x
    global y
    global Tabl
    global ListeCar
    global CoorCarA
    global CoorCarB
    for f in range (0,2):
        for i in range (len(ListeCar)):
            a=CoorCarA[i]*30
            b=CoorCarB[i]*30
            dx=x-a
            dy=y-b
            for g in range (0,1):
                if dx==0:
                    if dy>0:
                        angle=0
                    if dy<0:
                        angle=180
                    if dy==0:
                        angle=360
                elif dy==0:
                    if dx>0:
                        angle=270
                    if dx<0:
                        angle=90
                else:
                    dxy=dy/dx
                    rad=atan(dxy)
                    angle=rad*57.295779513082
                    if dy<0:
                        if dx<0:
                            angle+=90
                        if dx>0:
                            angle+=270
                    if dy>0:
                        if dx<0:
                            angle+=90
                        if dx>0:
                            angle+=270
            if (0<=angle<=22.5) or (360>=angle>337.5):
                #bas
                b=b+30
                CoorCarB[i]=CoorCarB[i]+1
                can.coords(ListeCar[i],a,b)
            if (22.5<angle<=67.5):
                #basgauche
                a=a-30
                b=b+30
                CoorCarA[i]=CoorCarA[i]-1
                CoorCarB[i]=CoorCarB[i]+1
                can.coords(ListeCar[i],a,b)
            if (67.5<angle<=112.5):
                #gauche
                a=a-30
                CoorCarA[i]=CoorCarA[i]-1
                can.coords(ListeCar[i],a,b)
            if (112.5<angle<=157.5):
                #hautgauche
                a=a-30
                b=b-30
                CoorCarA[i]=CoorCarA[i]-1
                CoorCarB[i]=CoorCarB[i]-1
                can.coords(ListeCar[i],a,b)
            if (157.5<angle<=202.5):
                #haut
                b=b-30
                CoorCarB[i]=CoorCarB[i]-1
                can.coords(ListeCar[i],a,b)
            if (202.5<angle<=247.5):
                #hautdroite
                a=a+30
                b=b-30
                CoorCarA[i]=CoorCarA[i]+1
                CoorCarB[i]=CoorCarB[i]-1
                can.coords(ListeCar[i],a,b)
            if (247.5<angle<=292.5):
                #droite
                a=a+30
                CoorCarA[i]=CoorCarA[i]+1
                can.coords(ListeCar[i],a,b)
            if (292.5<angle<=337.5):
                #basdroite
                a=a+30
                b=b+30
                CoorCarA[i]=CoorCarA[i]+1
                CoorCarB[i]=CoorCarB[i]+1
                can.coords(ListeCar[i],a,b)         
 
class Application(Frame):
    def Left(self):
        global x
        global y
        global Tabl
        #xx=x//30
        #yy=y//30
        #yyyy=Tabl[yy]
        #yyyy.append(xx)
        #yyyy.sort()
        #Tabl[yy]=yyyy
        x=x-30
        #xx=xx-1
        #yyy=Tabl[yy]
        #yyy.remove(xx)
        #Tabl[yy]=yyy
 
        ############################# avec touches pavé num?
        #def left(event):
            #global x
            #global y
            #x=x-30
            #can.coords(Per,x,y)
            #fen.unbind('<Left>')
 
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        can.coords(Per,x,y)
        self.quit()
 
    def Right(self):
        global x
        global y
        global Tabl
        x=x+30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def TopRight(self):
        global x
        global y
        global Tabl
        x=x+30
        y=y-30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def BottomRight(self):
        global x
        global y
        global Tabl
        x=x+30
        y=y+30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def TopLeft(self):
        global x
        global y
        global Tabl
        x=x-30
        y=y-30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def BottomLeft(self):
        global x
        global y
        global Tabl
        x=x-30
        y=y+30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def Top(self):
        global x
        global y
        global Tabl
        y=y-30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def Bottom(self):
        global x
        global y
        global Tabl
        y=y+30
        if x<0:
            x=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y<0:
            y=0
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if x>=510:
            x=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        if y>=510:
            y=480
            showinfo("Error","Vous etes hors-limite! Vous perdez votre tour")
        else:
            can.coords(Per,x,y)
        self.quit()
 
    def createWidgets(self):
        self.LEFT = Button(self)
        self.LEFT["text"] = "Gauche"
        self.LEFT["fg"]   = "blue"
        self.LEFT["command"] =  self.Left
        self.LEFT.pack({"side": "left"})
 
        self.RIGHT = Button(self)
        self.RIGHT["text"] = "Droite"
        self.RIGHT["fg"]   = "purple"
        self.RIGHT["command"] = self.Right
        self.RIGHT.pack({"side": "right"})
 
        self.TOPRIGHT = Button(self)
        self.TOPRIGHT["text"] = "HautDroite"
        self.TOPRIGHT["fg"]   = "green"
        self.TOPRIGHT["command"] = self.TopRight
        self.TOPRIGHT.pack({"side": "right"})
 
        self.BOTTOMRIGHT = Button(self)
        self.BOTTOMRIGHT["text"] = "BasDroite"
        self.BOTTOMRIGHT["fg"]   = "red"
        self.BOTTOMRIGHT["command"] = self.BottomRight
        self.BOTTOMRIGHT.pack({"side": "right"})
 
        self.TOPLEFT = Button(self)
        self.TOPLEFT["text"] = "HautGauche"
        self.TOPLEFT["fg"]   = "green"
        self.TOPLEFT["command"] = self.TopLeft
        self.TOPLEFT.pack({"side": "left"})
 
        self.BOTTOMLEFT = Button(self)
        self.BOTTOMLEFT["text"] = "BasGauche"
        self.BOTTOMLEFT["fg"]   = "red"
        self.BOTTOMLEFT["command"] = self.BottomLeft
        self.BOTTOMLEFT.pack({"side": "left"})
 
        self.TOP = Button(self)
        self.TOP["text"] = "Haut"
        self.TOP["fg"]   = "green"
        self.TOP["command"] =  self.Top
        self.TOP.pack({"side": "top"})
 
        self.BOTTOM = Button(self)
        self.BOTTOM["text"] = "Bas"
        self.BOTTOM["fg"]   = "red"
        self.BOTTOM["command"] =  self.Bottom
        self.BOTTOM.pack({"side": "bottom"})
 
    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()
 
#def test(event):
#   if event.char==True:
 
#Boutons enu
def alert():
    showinfo("Test", "Jouer?")
def New():
    newGame()
def Edit():
    a=input()
def Aide():
    showinfo("Aide","Le jeu se deroule en une succession de niveaux. \n * Chaque niveau demarre avec vous, le joueur, positionne au milieu de l'enclos (rectangulaire ou carre) des dinosaures.\n * Vous commencez chaque niveau avec un STP non charge.\n * Des dinosaures sont positionnes aleatoirement dans l'enclos a chaque debut de niveau.\n * Chaque niveau est divisé en tours, chaque tour permettant : \n - de vous déplacer sur un des huits emplacements voisins à votre position actuelle (sauf si un emplacement\n contient un dinosaure, ou d'utiliser votre STP pour vous téléporter.\n  Si votre STP n'est pas chargé, vous serez téléporté à une position aléatoire (éventuellement celle\n d'un dinosaure).\n  Si votre STP est chargé, vous serez téléporté à une position sûre dans l'enclos.\n - Après avoir effectué votre déplacement, les dinosaures se déplacent à leur tour :\n  L' Acrocanthosaure se déplace d'une seule case\n  Carnotaurus se déplace de deux cases\n  Les dinosaures se déplacent en ligne droite vers la position du joueur\n - Si deux dinosaures se déplacent sur la même case, ils se battent et meurent, laissant leur cadavre.\n - Si un dinosaure se déplace sur une case contenant le cadavre d'un autre dinosaure, il le mange et meurt,\n laissant son cadavre.\n - Si un dinosaure se déplace sur la case qui contient le joueur, vous êtes mort et la partie se termine.\n * Si le joueur arrive sur une case où il pense être en sécurité, il peut recharger son STP, mais ne peut pas\n bouger ; les dinosaures continuent de se déplacer.\n - Chaque tour permet au joueur de recharger son STP d'une unité (i.e. une téléportation dans un endroit sûr).\n * Le niveau se termine lorsque les dinosaures sont tous morts ou bien lorsque le joueur se fait dévorer.\n - Si le joueur reste en vie, un nouveau niveau commence avec un nombre de dinosaures plus élevé.")
#Fin boutons menu
 
 
###########
#         #
#  Init : #
#         #
###########
STP=0
NumeroAcro=-1
NumeroCarno=-1
NumeroCarcasse=-1
 
Pos0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos4=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos5=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos6=[0,1,2,3,4,5,11,12,13,14,15,16]
Pos7=[0,1,2,3,4,5,11,12,13,14,15,16]
Pos8=[0,1,2,3,4,5,11,12,13,14,15,16]
Pos9=[0,1,2,3,4,5,11,12,13,14,15,16]
Pos10=[0,1,2,3,4,5,11,12,13,14,15,16]
Pos11=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos12=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos13=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos14=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos15=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Pos16=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Tabl=[Pos0,Pos1,Pos2,Pos3,Pos4,Pos5,Pos6,Pos7,Pos8,Pos9,Pos10,Pos11,Pos12,Pos13,Pos14,Pos15,Pos16]
 
Sur0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur4=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur5=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur6=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur7=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur8=[0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16]
Sur9=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur10=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur11=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur12=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur13=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur14=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur15=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
Sur16=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
SurTabl=[Sur0,Sur1,Sur2,Sur3,Sur4,Sur5,Sur6,Sur7,Sur8,Sur9,Sur10,Sur11,Sur12,Sur13,Sur14,Sur15,Sur16]
 
ListeAcr=[]
ListeCar=[]
ListeCarcasse=[]
CoorAcrA=[]
CoorAcrB=[]
CoorCarA=[]
CoorCarB=[]
CoorCarcasseA=[]
CoorCarcasseB=[]
 
 
fen = Tk()
can = Canvas(fen, width=510, height=510, bg='#4ca64c')
can.pack(side=TOP, padx=5, pady=5)
 
###########
#         #
#  Menu : #
#         #
###########
 
menubar = Menu(fen)
 
menu1 = Menu(menubar, tearoff=0)
menu1.add_command(label="Créer une nouvelle partie", command=New)
menu1.add_command(label="Editer", command=Edit)
menu1.add_separator()
menu1.add_command(label="Quitter", command=fen.destroy)
menubar.add_cascade(label="Fichier", menu=menu1)
 
menu2 = Menu(menubar, tearoff=0)
menu2.add_command(label="Haut", command=alert)
menu2.add_command(label="Bas", command=alert)
menu2.add_command(label="Gauche", command=alert)
menu2.add_command(label="Droite", command=alert)
menubar.add_cascade(label="Jouer", menu=menu2)
 
menu3 = Menu(menubar, tearoff=0)
menu3.add_command(label="A propos", command=Aide)
menubar.add_cascade(label="Aide", menu=menu3)
 
fen.config(menu=menubar)
 
 
 
 
#######################################
#                                     #
#        Images :                    #
#                                     #
#######################################
 
#Il faut impérativement mettre les images dans le dossier telechargement
 
#Recuperer perso
Perso=PhotoImage(file='.\Personnage.png')
#fin Recuperer perso
 
#Recuperer Acro
Acro=PhotoImage(file='.\Acrocanthosaure.png')
#fin Recuperer Acro
 
#Recuperer Carno
Carno=PhotoImage(file='.\Carnotaurus.png')
#fin Recuperer Carno
 
#Recuperer Carcasse
Carcasse=PhotoImage(file='.\Carcasse.png')
#fin Recuperer Carcasse
 
 
#######################################
#                                     #
#        Programme principal :        #
#                                     #
#######################################
 
Joueur=1
niveau=1
 
while (Joueur==1):
 
    x = 242
    y = 242
    tex2=Label(fen,text='Niveau '+str(niveau))
    tex2.pack(padx=0, pady=11)
    tex1=Label(fen, text="A 3 STP vous pouvez vous téléporter sûrement. Votre STP est de " +str(STP), fg='#333333')
    tex1.pack(padx=0, pady=11)
    Pos0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos4=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos5=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos6=[0,1,2,3,4,5,11,12,13,14,15,16]
    Pos7=[0,1,2,3,4,5,11,12,13,14,15,16]
    Pos8=[0,1,2,3,4,5,11,12,13,14,15,16]
    Pos9=[0,1,2,3,4,5,11,12,13,14,15,16]
    Pos10=[0,1,2,3,4,5,11,12,13,14,15,16]
    Pos11=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos12=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos13=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos14=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos15=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Pos16=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Tabl=[Pos0,Pos1,Pos2,Pos3,Pos4,Pos5,Pos6,Pos7,Pos8,Pos9,Pos10,Pos11,Pos12,Pos13,Pos14,Pos15,Pos16]
    Sur0=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur1=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur2=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur3=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur4=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur5=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur6=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur7=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur8=[0,1,2,3,4,5,6,7,9,10,11,12,13,14,15,16]
    Sur9=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur10=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur11=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur12=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur13=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur14=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur15=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    Sur16=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
    SurTabl=[Sur0,Sur1,Sur2,Sur3,Sur4,Sur5,Sur6,Sur7,Sur8,Sur9,Sur10,Sur11,Sur12,Sur13,Sur14,Sur15,Sur16]
 
    x1,x2,y1,x3,y3,y4 = 0,0,510,510,0,0
    dx, dy = 0,0
    flag = 0
    drawline()
    drawline2()
    #Recup Perso
    Per=can.create_image(x, y, anchor=NW, image=Perso)
    #fin recuperation Perso
    for niv in range (1,(niveau)+1):
        if (niv==1):
            for nbAcrocanthosaureDebut in range (0,3):
                NumeroAcro+=1
                b=randint(0,16)
                atabl=Tabl[b]
                le=len(atabl)
                while (le==0):
                    b=randint(0,16)
                    atabl=Tabl[b]
                    le=len(atabl)
                i=randint(0,le-1)
                a=atabl[i]
                bbb=Tabl[b]
                bbb.remove(a)
                Tabl[b]=bbb
                bsur=SurTabl[b]
                bsur.remove(a)
                SurTabl[b]=bsur
                CoorAcrA.append(a)
                CoorAcrB.append(b)
                a=a*30
                b=b*30
                ListeAcr.append(can.create_image(a, b, anchor=NW, image=Acro))
        #fin recuperation Acro
        elif (niv>1):
            #Recup Acro
            for nbAcrocanthosaureAjoutes in range (0,2):
                NumeroAcro+=1
                b=randint(0,16)
                atabl=Tabl[b]
                le=len(atabl)
                while (le==0):
                    b=randint(0,16)
                    atabl=Tabl[b]
                    le=len(atabl)
                i=randint(0,le-1)
                a=atabl[i]
                bbb=Tabl[b]
                bbb.remove(a)
                Tabl[b]=bbb
                bsur=SurTabl[b]
                bsur.remove(a)
                SurTabl[b]=bsur
                CoorAcrA.append(a)
                CoorAcrB.append(b)
                a=a*30
                b=b*30
                ListeAcr.append(can.create_image(a, b, anchor=NW, image=Acro))
            #fin recuperation Acro
            if (niv==3):
                #Recup Carno
                NumeroCarno+=1
                d=randint(0,16)
                ctabl=Tabl[d]
                le=len(ctabl)
                while (le==0):
                    d=randint(0,16)
                    ctabl=Tabl[d]
                    le=len(ctabl)
                i=randint(0,le-1)
                c=ctabl[i]
                ddd=Tabl[d]
                ddd.remove(c)
                Tabl[d]=ddd
                dsur=SurTabl[d]
                dsur.remove(c)
                SurTabl[d]=dsur
                CoorCarA.append(c)
                CoorCarB.append(d)
                c=c*30
                d=d*30
                ListeCar.append(can.create_image(c, d, anchor=NW, image=Carno))
                #fin recuperation Carno
            elif (niv>3):
                for nbCarnotaurusAjoutes in range (0,2):
                    #Recup Carno
                    NumeroCarno+=1
                    d=randint(0,16)
                    ctabl=Tabl[d]
                    le=len(ctabl)
                    while (le==0):
                        d=randint(0,16)
                        ctabl=Tabl[d]
                        le=len(ctabl)
                    i=randint(0,le-1)
                    c=ctabl[i]
                    ddd=Tabl[d]
                    ddd.remove(c)
                    Tabl[d]=ddd
                    dsur=SurTabl[d]
                    dsur.remove(c)
                    SurTabl[d]=dsur
                    CoorCarA.append(c)
                    CoorCarB.append(d)
                    c=c*30
                    d=d*30
                    ListeCar.append(can.create_image(c, d, anchor=NW, image=Carno))
                    #fin recuperation Carno
    tour=1
    while tour==1:
        STPASK()
        DptAcro()
        DptCarno()
        ok=0
        while ok==0:
            g=-1
            test=0
            for i in ListeAcr:
                g+=1
                h=-1
                if test==1:
                    break
                for j in ListeCar:
                    h+=1
                    if test==1:
                        break
                    if CoorAcrA[g]==CoorCarA[h]:
                        if CoorAcrB[g]==CoorCarB[h]:
                            NumeroCarcasse+=1
                            a=CoorAcrA[g]
                            b=CoorAcrB[g]
                            c=CoorCarA[h]
                            d=CoorCarB[h]
                            CoorAcrA.remove(a)
                            CoorAcrB.remove(b)
                            CoorCarA.remove(c)
                            CoorCarB.remove(d)
                            ListeAcr[g]=can.delete()
                            ListeCar[h]=can.delete()
                            CoorCarcasseA.append(a)
                            CoorCarcasseB.append(b)
                            a=a*30
                            b=b*30
                            ListeCarcasse.append(can.create_image(a, b, anchor=NW, image=Carcasse))
                            test=1
            if test==0:
                ok=1
        ok=0
        while ok==0:
            g=-1
            test=0
            for i in ListeAcr:
                g+=1
                h=-1
                if test==1:
                    break
                for j in ListeAcr:
                    h+=1
                    if test==1:
                        break
                    if i!=j:
                        if CoorAcrA[g]==CoorAcrA[h]:
                            if CoorAcrB[g]==CoorAcrB[h]:
                                NumeroCarcasse+=1
                                a=CoorAcrA[g]
                                b=CoorAcrB[g]
                                c=CoorAcrA[h]
                                d=CoorAcrB[h]
                                CoorAcrA.remove(a)
                                CoorAcrB.remove(b)
                                CoorAcrA.remove(c)
                                CoorAcrB.remove(d)
                                ListeAcr[g]=can.delete()
                                ListeAcr[h]=can.delete()
                                CoorCarcasseA.append(a)
                                CoorCarcasseB.append(b)
                                a=a*30
                                b=b*30
                                ListeCarcasse.append(can.create_image(a, b, anchor=NW, image=Carcasse))
                                test=1
            if test==0:
                ok=1
        g=-1
        for i in ListeCar:
            g+=1
            h=-1
            for j in ListeCar:
                h+=1
                if i!=j:
                    if CoorCarA[g]==CoorCarA[h]:
                        if CoorCarB[g]==CoorCarB[h]:
                            NumeroCarcasse+=1
                            a=CoorCarA[g]
                            b=CoorCarB[g]
                            c=CoorCarA[h]
                            d=CoorCarB[h]
                            CoorCarA.remove(a)
                            CoorCarB.remove(b)
                            CoorCarA.remove(c)
                            CoorCarB.remove(d)
                            ListeCar[g]=can.delete()
                            ListeCar[h]=can.delete()
                            CoorCarcasseA.append(a)
                            CoorCarcasseB.append(b)
                            a=a*30
                            b=b*30
                            ListeCarcasse.append(can.create_image(a, b, anchor=NW, image=Carcasse))
        for i in range (len(ListeCar)):
            a=CoorCarA[i]*30
            b=CoorCarB[i]*30
            if a==x:
                if b==y:
                    tour=0
                    Joueur=0
                    showinfo("Perdu","Vous avez perdu!")
        for i in range (len(ListeAcr)):
            a=CoorAcrA[i]*30
            b=CoorAcrB[i]*30
            if a==x:
                if b==y:
                    tour=0
                    Joueur=0
                    showinfo("Perdu","Vous avez perdu!")
        for i in range (len(ListeCarcasse)):
            a=CoorCarcasseA[i]*30
            b=CoorCarcasseA[i]*30
            if a==x:
                if b==y:
                    tour=0
                    Joueur=0
                    showinfo("Perdu","Vous avez perdu!")
        if len(ListeAcr)==0:
            tour=0
        if niveau >=3:
            if len(ListeCar)==0:
                tour=0
 
 
    can.delete(ALL)
    tex1.destroy()
    tex2.destroy()
    niveau+=1
Merci bcp