number.py

Created by chambounaudaubin

Created on September 16, 2025

4.32 KB

/!\ peut paraitre rapide sur la calculatrice numworks N0120…à signaler!

Reporter tous les bugs à chambounaudaubin@gmail.com


from math import *
from kandinsky import *
from ion import *
from time import *
from random import *
x=155
y=105
xc=[]
yc=[]
nbc=20
r,g,b=200,255,200
plan=(240,240,255)
step=2
colonnes=[0,37,74,111,148,185,222,259,296,333]
lignes=[0,37,74,111,148,185,222]
movx=[]
movy=[]
valeurs=[]
attract=0.5
na=0
t=0
ch=0
score=0
go=1
time=0
for i in range(nbc):
  na=randint(1,2) 
  if na==1:xc.append(randint(0,120))
  if na==2:xc.append(randint(180,320)) 
for i in range(nbc):yc.append(randint(0,222)) 
def player(a,b):fill_rect(a,b,10,10,color(0,0,100))
for i in range(nbc):
  d=randint(1,2)
  if d==1:movx.append(randint(1,10))
  if d==2:movx.append(randint(-10,-1))
  d=randint(1,2)
  if d==1:movy.append(randint(1,10))
  if d==2:movy.append(randint(-10,-1))
for i in range(nbc/4):
  for i in range(3):valeurs.append(randint(-5,-1))
  valeurs.append(randint(1,5))
def cibles(c,d):
  if valeurs[i]<0:fill_rect(c,d,10,10,color(200,0,0))
  if valeurs[i]>0:fill_rect(c,d,10,10,color(0,200,0))
  fill_rect(c-2*step,d-2*step,10+4*step,2*step,color(plan))
  fill_rect(c-step*2,d-step*2,step*2,10+4*step,color(plan))
  fill_rect(c+10,d,step*2,10+2*step,color(plan))
  fill_rect(c,d+10,10+2*step,step*2,color(plan))
fill_rect(0,0,320,222,color(plan))
while go==1:
  for i in range(nbc):
    xc[i]=xc[i]+movx[i]/10
    yc[i]=yc[i]+movx[i]/10
  player(x,y)
  for i in range(nbc):cibles(int(xc[i]),int(yc[i]))
  for i in range(len(xc)):
    if xc[i]<-10:
      xc[i]=xc[i]-xc[i]+320
      movx[i]=movx[i]-movx[i]+randint(-10,-1)
    if xc[i]>320:
      xc[i]=xc[i]-xc[i]-10
      movx[i]=movx[i]-movx[i]+randint(1,10)  
    if yc[i]<-10:
      yc[i]=yc[i]-yc[i]+222
      movy[i]=movy[i]-movy[i]+randint(-10,-1)
    if yc[i]>222:
      yc[i]=yc[i]-yc[i]-10
      movy[i]=movy[i]-movy[i]+randint(1,10)
  if keydown(KEY_DOWN):
    for i in range(len(yc)):yc[i]=yc[i]-step
    for i in range(len(lignes)):lignes[i]=lignes[i]-step
    for i in range(len(lignes)):fill_rect(0,lignes[i]+step,320,step,color(plan))
    for i in range(len(lignes)):
      if lignes[i]<0:lignes[i]=lignes[i]+259
  if keydown(KEY_UP):
    for i in range(len(yc)):yc[i]=yc[i]+step
    for i in range(len(lignes)):lignes[i]=lignes[i]+step
    for i in range(len(lignes)):fill_rect(0,lignes[i]-step,320,step,color(plan))
    for i in range(len(lignes)):
      if lignes[i]>222:lignes[i]=lignes[i]-259
  if keydown(KEY_LEFT):
    for i in range(len(xc)):xc[i]=xc[i]+step
    for i in range(len(colonnes)):colonnes[i]=colonnes[i]+step
    for i in range(len(colonnes)):fill_rect(colonnes[i]-step,0,step,222,color(plan))
    for i in range(len(colonnes)):
      if colonnes[i]>333:colonnes[i]=colonnes[i]-370
  if keydown(KEY_RIGHT):
    for i in range(len(xc)):xc[i]=xc[i]-step
    for i in range(len(colonnes)):colonnes[i]=colonnes[i]-step
    for i in range(len(colonnes)):fill_rect(colonnes[i]+step,0,step,222,color(plan))
    for i in range(len(colonnes)):
      if colonnes[i]<0:colonnes[i]=colonnes[i]+370
  for i in range(len(lignes)):fill_rect(0,lignes[i],320,1,color(200,200,200))
  for i in range(len(colonnes)):fill_rect(colonnes[i],0,1,222,color(200,200,200))
  for i in range(nbc):
    if xc[i]<x and x-xc[i]<300:xc[i]=xc[i]+attract
    if xc[i]>x and xc[i]-x<300:xc[i]=xc[i]-attract
    if yc[i]<y and y-yc[i]<300:yc[i]=yc[i]+attract
    if yc[i]>y and yc[i]-y<300:yc[i]=yc[i]-attract
  for i in range(nbc):
    if x+10>xc[i] and x<xc[i]+10 and y+10>yc[i] and y<yc[i]+10 and valeurs[i]<0:go=0
    if x+10>xc[i] and x<xc[i]+10 and y+10>yc[i] and y<yc[i]+10 and valeurs[i]>0 and ch==0:
      score=score+1
      ch=1
      taille=10
      xv,yv=xc[i],yc[i]
      r,g,b=0,200,0
      fill_rect(int(xc[i]),int(yc[i]),10,10,color(plan))
      xc[i],yc[i]=xc[i]-xc[i]-10,yc[i]-yc[i]-randint(0,200)
  if ch>0 and ch<20:
    ch,taille,xv,yv,r,g,b=ch+1,taille+2,xv-1,yv-1,r+12,g+2,b+12.6
    fill_rect(int(xv),int(yv),taille,taille,color(r,g,b))
    draw_string(str(score),x,y-20,color(r,b,g),color(plan))
  elif ch>=20:ch=0
  time=time+1
  sleep(0.01)
sleep(0.5)
r,g,b=0,0,0
for x in range(0,320,10):
  for y in range(0,222,10):
    b,r,g=0.05*x*0.05*y,0.05*x*0.05*y,0.05*x*0.05*y
    fill_rect(x,y,10,10,color(r,g,b))
    sleep(0.001)
draw_string("BRAVO! TON SCORE EST:",55,100,"white","black")
draw_string(str(score),150,120,"white","black")
draw_string("JEU PAR AUBIN",95,140,"white","black")
#reporter tous les bugs a chambounaudaubin@gmail.com

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.