neige.py

Created by schraf

Created on September 28, 2020

666 Bytes

Appuyez plusieurs fois sur la touche “Retour” à côté de “OK” pour arrêter le script.


from random import *
from kandinsky import *
from time import sleep

nb = 120
st = [0]*nb
pr = [0]*nb
NR = (0,0,0)

def point():
  return [randrange(320),0,randrange(1,10)]

def init():
  fill_rect(0,0,320,222,NR)
  for i in range(nb): st[i] = point()

def go():
  init()
  while True:
    sleep(.05)
    for i in range(nb):
      st[i][1] += randrange(1,int(50/st[i][2]))
      z = st[i][2]
      px = st[i][0]
      py = min(240,st[i][1])
      if py >= 240: st[i] = point()
      if pr[i] != 0: set_pixel(pr[i][0],pr[i][1],NR)
      pr[i] = [int(px),int(py)]
      c = int((1 - z/10) * 255)
      set_pixel(pr[i][0],pr[i][1],color(c,c,c))
      
go()

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