eclaire.py

Created by marius-layan

Created on February 05, 2024

655 Bytes

Simulation d’éclaires (ça rend encore mieux en accéléré)


from random import *
from kandinsky import *
from ion import *
from time import *
def eclaire():
  l,a,t=[[randint(0,320),0,255]],0,monotonic();fill_rect(0,0,320,222,'black')
  while l!=[]:
    sleep(0.01-monotonic()+t);t=monotonic();l.append([l[-1][0],a,255]);l[-1][1]+=1;l[-1][0]+=randint(-2,2);a+=2
    while True:
      comt=0
      for i in range(len(l)):
        fill_rect(int(l[i][0]),int(l[i][1]),1,3,(0,0,l[i][2]));l[i][2]-=2
        if l[i][2]==1 or l[i][1]<0 or l[i][1]>222 or l[i][0]<0 or l[i][0]>320:del l[i];break
        comt+=1
      if len(l)==comt:break
eclaire()
while True:
  if randint(0,100)==0:eclaire()
  sleep(0.05)

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 cookies policy.