ttt.py

Created by schraf

Created on November 05, 2021

914 Bytes


from math import *
from turtle import *
from kandinsky import fill_rect
from random import randint
from time import sleep

hideturtle()
pensize(2)
speed(9)

def grille():
    for i in range(2):
        fill_rect(75,80 + 60 * i, 180,1,(0,0,0))
        fill_rect(130 + 60 * i,20, 1,180,(0,0,0))

def dessin(c,l,f=1): # col+ligne+figure
 fill_rect(135 + 60 * c, 85 - 60 * l, 50,50,(255,255,255))
 penup()
 color((0,0,0))
 if f == 1: # cercle
    goto(c * 60 + 20, l * 60)
    pendown()
    for k in range(17):
        a = pi * k / 6
        goto(60 * c + 20 * cos(a), 60 * l + 20* sin(a)) 
 else: # croix
    goto(c * 60 - 20, l * 60 - 20)
    pendown()   
    goto(c * 60 + 20, l * 60 + 20)
    penup()
    goto(c * 60 - 20, l * 60 + 20)
    pendown()   
    goto(c * 60 + 20, l * 60 - 20)    

grille()
while True:
    x = randint(-1,1)
    y = randint(-1,1)
    dessin(x,y,randint(0,1))
    #sleep(.1)