sand.py

Created by schraf

Created on January 15, 2023

572 Bytes

Vidéo TikTok de ce script | En savoir plus (En anglais)
Le script plante parfois avec le simulateur mais devrait bien tourner sur votre NUMWORKS N110 ou N120

Ma chaine Youtube


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

COUL=(24,40,80),(248,240,24),(248,200,168),(253,160,0)
gp,fr,rd=get_pixel,fill_rect,randint

def sp(p,c): fr(2*p[0],2*p[1],2,2,COUL[c])
def alea(n):return [rd(75,85),rd(0,n),rd(1,2)] 

fr(0,0,320,222,COUL[0])
fr(0,190,320,4,COUL[3])
s=[alea(90) for _ in range(200)]
while True:
 for (i,p) in enumerate(s):
  sp(p,0)
  m=0
  for j in 0,2,-2:
   if gp(2*p[0]+j,2*p[1]+2)==COUL[0]:
    s[i][0]+=j; s[i][1]+=2
    m=1
  sp(p,p[2])
  if m==0:
   if random()<.5:sp(p,3)
   s[i]=alea(3)
 sleep(.01)

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.