ecrandeveille.py

Created by thibaut-lyon

Created on March 28, 2022

1.54 KB


from math import *
from kandinsky import *
from random import *  
from ion import *
def point(): #Initialise les carrés
  return[randrange(-160,160),randrange(-120,120),randrange(1,10)]

nb=60
st=[0]*nb
pr=[0]*nb

def init():
  for i in range(320*240):
    set_pixel(i%320,i//320,color(0,0,0))
  for i in range(nb):
    st[i]=point()

def go(nb): #Démarrer le programme
  init()
  while True:
    for i in range(nb):
      st[i][2]-=0.2
      if st[i][2]<=0:
        st[i]=point()
      z=st[i][2]
      px=min(320,max(-1,st[i][0]/z+160))
      py=min(240,max(-1,st[i][1]/z+120))        
      if pr[i]!=0:
        set_pixel(pr[i][0],pr[i][1],color(0,0,9))
      pr[i]=[int(px),int(py)]
      c=int((1-z/10)*255)
      set_pixel(pr[i][0],pr[i][1],color(255-c,c,3*c))
    if keydown(KEY_SHIFT):
      break
    if keydown(KEY_ALPHA):
      for i in range(320*240):
        set_pixel(i%320,i//320,color(250,250,250))
        if keydown(KEY_SHIFT):
          break
      for i in range(nb):
        st[i]=point()
        if keydown(KEY_SHIFT):
          break
      while True:
        for i in range(nb):
          st[i][2]-=0.2
          if st[i][2]<=0:
            st[i]=point()
          z=st[i][2]
          px=min(320,max(-1,st[i][0]/z+160))
          py=min(240,max(-1,st[i][1]/z+120))        
          if pr[i]!=0:
            set_pixel(pr[i][0],pr[i][1],color(0,0,9))
          pr[i]=[int(px),int(py)]
          c=int((1-z/10)*255)
          set_pixel(pr[i][0],pr[i][1],color(255-c,c,3*c))
        if keydown(KEY_SHIFT):
          break

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.