bonjour !

alors voila pour terminer un tres long programme, je vous faire une sorte de snake sur tkinter

j'ai deja fait cela
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
# -*- coding: cp1252 -*-
from Tkinter import*
Fen = Tk()
Fen.title('Jeu Final')
from random import randrange
#placement du carré
x = 235
y = 250
 
def newGame():
    global x
    global y
 
    #création de l'objet a attraper
    pX = randrange(5, 495)
    pY = randrange(5, 495)
    canevas.create_oval(pX, pY, pX+5, pY+5, outline='white', fill='green')
    #création de l'obstacle
    pX = randrange(5, 495)
    pY = randrange(5, 495)
    canevas.create_rectangle(pX, pY, pX+20, pY+10, outline='black', fill='black')           
 
#mise ne mouvement possible du carré
    direction = ''
    canevas.coords(carre, x, y, x+10, y+10)
 
    #utilisation des fleches du clavier
    Fen.bind("<Right>", right)
    Fen.bind('<Left>', left)
    Fen.bind('<Up>' , up)
    Fen.bind('<Down>', down)
 
 
def move():
    global x
    global y
#mise en mouvement
    if direction  == 'gauche':
        x  = x - 5
    elif direction  == 'droite':
        x  = x + 5
    elif direction  == 'haut':
        y  = y - 5
    elif direction  == 'bas':
        y  = y + 5
    canevas.coords(carre, x, y, x+10, y+10)
    Fen.after(700, move)
#Si sortie d'un coté, entrée de l'autre coté
    if y > 500:
        y = 0
    elif y < 0:
        y = 500
    if x > 500:
        x = 0
    elif x < 0:
        x = 500
#end def move
 
#directions
def left(event):
    global direction
    direction = 'gauche'
    move ()
#end def left    
def right(event):
    global direction
    direction = 'droite'
    move ()
#end def right   
def up(event):
    global direction
    direction = 'haut'
    move ()
#end def up    
def down(event):
    global direction
    direction = 'bas'
    move ()
#end def up
 
if carre=oval:
    oval.destroy()
    oval+1
    rectangle +=2
 
 
 
#parametres du fond
canevas = Canvas(Fen, width=500, height=500, bg='#046380')
canevas.pack(side=TOP, padx=5, pady=5)
#parametre du carré
carre = canevas.create_rectangle(x, y, x+10, y+10, outline='white', fill='#C03000')
#paramètres des boutons
b1 = Button(Fen, text='New Game', command=newGame)
b1.pack(side=LEFT, padx=5, pady=5)
b2 = Button(Fen, text='Quitter', command=Fen.destroy)
b2.pack(side=RIGHT, padx=5, pady =5)
#paramètre consignes
tex1 = Label(Fen, text="Cliquez sur 'New Game' pour commencer")
tex1.pack(padx=0, pady=11)
 
 
Fen.mainloop()
j'aimerai que le rond vert disparaisse quand le carré rouge passe dessus. des quil passe dessus une autre rond se cree et deux rectangles noirs doivent apparaître, bien entendu on meurt quand on touche les rectangles noirs. le 'serpents' ne s'allongera pas mais il y aura une limite de clics pour la surivie du serpent'.

merci d'avance