jeu de morpion diriger le carré bleu vers le carré ou vous voulez aller puis appuyer sur OK
from turtle import * from ion import * from kandinsky import * from time import * hideturtle() speed(10) penup() goto(15,-45) pendown() setheading(90) forward(90) penup() goto(-15,-45) pendown() forward(90) penup() goto(-45,15) pendown() setheading(0) forward(90) penup() goto(-45,-15) pendown() forward(90) tour=1 x=y=s=sept=huit=neuf=quatre=cinq=six=un=deux=trois=0 def ok(x,y): fill_rect(x,y,22,22,color(45,213,231)) def blanc(x,y): fill_rect(x,y,26,26,color('white')) pensize(3) def croix(x,y): penup() goto(x,y) setheading(-90) for i in range(2): pendown() right(135) forward(30) penup() right(135) forward(21) def rond(x,y): penup() goto(x,y) pendown() circle(10) def debut(): blanc(117,68) blanc(117,98) blanc(117,128) blanc(147,68) blanc(147,98) blanc(147,128) blanc(177,68) blanc(177,98) blanc(177,128) while s==0: sleep(0.1) if keydown(KEY_UP): if y<1: y=y+1 if keydown(KEY_DOWN): if y>-1: y=y-1 if keydown(KEY_RIGHT): if x<1: x=x+1 if keydown(KEY_LEFT): if x>-1: x=x-1 if sept==0: if x==-1 and y==1: ok(119,70) else: blanc(119,70) if quatre==0: if x==-1 and y==0: ok(119,100) else: blanc(119,100) if un==0: if x==-1 and y==-1: ok(119,130) else: blanc(119,130) if huit==0: if x==0 and y==1: ok(149,70) else: blanc(149,70) if cinq==0: if x==0 and y==0: ok(149,100) else: blanc(149,100) if deux==0: if x==0 and y==-1: ok(149,130) else: blanc(149,130) if neuf==0: if x==1 and y==1: ok(179,70) else: blanc(179,70) if six==0: if x==1 and y==0: ok(179,100) else: blanc(179,100) if trois==0: if x==1 and y==-1: ok(179,130) else: blanc(179,130) if keydown(KEY_OK): if x==-1 and y==1 and sept==0: blanc(119,70) if tour==1: croix(-19,20) else: rond(-20,30) sept=tour if x==-1 and y==0 and quatre==0: blanc(119,100) if tour==1: croix(-19,-11) else: rond(-20,-1) quatre=tour if x==-1 and y==-1 and un==0: blanc(119,130) if tour==1: croix(-19,-41) else: rond(-20,-31) un=tour if x==0 and y==1 and huit==0: blanc(149,70) if tour==1: croix(11,20) else: rond(10,30) huit=tour if x==0 and y==0 and cinq==0: blanc(149,100) if tour==1: croix(11,-10) else: rond(10,0) cinq=tour if x==0 and y==-1 and deux==0: blanc(149,130) if tour==1: croix(11,-40) else: rond(10,-30) deux=tour if x==1 and y==1 and neuf==0: blanc(179,70) if tour==1: croix(42,20) else: rond(40,30) neuf=tour if x==1 and y==0 and six==0: blanc(179,100) if tour==1: croix(42,-10) else: rond(40,0) six=tour if x==1 and y==-1 and trois==0: blanc(179,130) if tour==1: croix(42,-40) else: rond(40,-30) trois=tour if tour==1: tour=2 else: tour=1 if sept==cinq==trois==1 or sept==quatre==un==1 or sept==huit==neuf==1 or neuf==six==trois==1 or un==deux==trois==1 or un==cinq==neuf==1 or quatre==cinq==six==1 or huit==cinq==deux==1: draw_string(" croix a gagne",80,200) s=0 while s==0: if keydown(KEY_OK): s=1 sept=huit=neuf=quatre=cinq=six=un=deux=trois=s=0 debut() sleep(0.1) if sept==cinq==trois==2 or sept==quatre==un==2 or sept==huit==neuf==2 or neuf==six==trois==2 or un==deux==trois==2 or un==cinq==neuf==2 or quatre==cinq==six==2 or huit==cinq==deux==2: draw_string(" rond a gagne ",80,200) s=0 while s==0: if keydown(KEY_OK): s=1 sept=huit=neuf=quatre=cinq=six=un=deux=trois=s=0 debut() sleep(0.1) if un!=0 and deux!=0 and trois!=0 and quatre!=0 and cinq!=0 and six!=0 and sept!=0 and huit!=0 and neuf!=0: sept=huit=neuf=quatre=cinq=six=un=deux=trois=s=0 draw_string(" echec ",80,200) while s==0: if keydown(KEY_OK): s=1 s=0 debut() sleep(0.1) if tour==1: draw_string("tour de croix",90,200) else: draw_string("tour de rond ",90,200)