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
|
from tkinter import*
from random import*
def damier():
#dessiner 100 lignes de carrés avec décalage
ligne=0
y=0
while ligne<10:
if ligne%2==0:
x=0
else:
x=65
ligne_de_carres(x,y)
y=y+65
ligne=ligne+1
ligne=0
y=0
while ligne<4:
if ligne%2==0:
x=0
else:
x=65
ligne_de_pion1(x,y)
y=y+65
ligne=ligne+1
ligne=6
y=390
while ligne<10:
if ligne%2==0:
x=0
else:
x=65
ligne_de_pion2(x,y)
y=y+65
ligne=ligne+1
def ligne_de_carres(x,y):
for k in range(5):
can.create_rectangle(x,y,x+65,y+65,fill="black")
x=x+130
def ligne_de_pion1(x,y):
global listblanc
for k in range(5):
can.create_oval(x,y,x+65,y+65,fill="green")
listblanc=listblanc+[[x,y]]
x=x+130
print (listblanc)
def ligne_de_pion2(x,y):
global listnoir
for k in range(5):
can.create_oval(x,y,x+65,y+65,fill="red")
listnoir=listnoir+[[x,y]]
x=x+130
print (listnoir)
def Clic(event):
""" """
# position du pointeur de la souris
X = event.x
Y = event.y
# on dessine un carré
r = 31
can.create_oval(X-r, Y-r, X+r, Y+r, outline='black',fill='red')
listblanc=[]
listnoir=[] |
Partager