Apprendre Python sur une Numworks
from random import * from kandinsky import * from time import * deco = ["+*o.=^^o","bbbvvvvr"] fill_rect(0,0,320,240,(0,0,0)) def rec(x,y,c,t): fill_rect(x,y,2*t,3*t,c) def sapin(): for i in range(14): for j in range(2*i+1): n = choice(range(8)) coul = {"v":(0,255,0),"b":(255,255,255),"r":(255,0,0)}[deco[1][n]] draw_string(deco[0][n],160-9*i+9*j,8+15*i,coul,(0,0,0)) t1=monotonic() t2=monotonic() neige=[[randint(0,320),randint(0,200)] for i in range(200)] sapin() while True: # Neige tombe if monotonic()-t1>.15: t1=monotonic() for i,v in enumerate(neige): rec(v[0],v[1],(0,0,0),1) v[1]+=randint(1,10) if v[1]>240: [v[0],v[1]]=[randint(0,320),0] c = (140,140,140) rec(v[0],v[1],c,1) # Nouveau sapin apres 10 sec if monotonic()-t2>10: t2=monotonic() sapin()