perseides.py

Created by schraf

Created on August 12, 2021

852 Bytes


from turtle import *
from kandinsky import set_pixel,fill_rect
from random import randint
from time import sleep

hideturtle()
speed(0)
fill_rect(0,0,320,222,(0,0,0))

# meteore partant de (x,y)
# de taille t, de direction d
# deplacement de longueur l
# et de couleur (c,c,c)

def perseide(x,y,t,d,l,c):
    penup()
    goto(x,y)
    pensize(t)
    setheading(d)
    color((c,) * 3)
    pendown()
    forward(l)
    penup()

# Les etoiles
for i in range(100):
    x,y,c = randint(0,320), randint(0,220), randint(100,255)
    set_pixel(x,y,(c,)*3)

while True:
    x,y = randint(-150,150), randint(-40,100)
    t,d = randint(1,2), randint(-180,0)
    c,l = randint(1,80), randint(20,100)
    # on affiche
    perseide(x,y,t,d,l,c)
    # on efface
    perseide(x,y,3,d,l,0)
    # temps alea entre 2 meteores
    sleep(randint(1,10)/10)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.