Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import pygame, sys
- from pygame.locals import *
- pygame.init()
- #variables COLOR
- WHITE = (255,255,255)
- BLUE = (0,0,255)
- GREEN = (0,255,0)
- RED = (255,0,0)
- BLACK = (0,0,0)
- PINK=(249,16,158)
- GRIS=(175,175,175)
- YELLOW=(255,215,0)
- ORANGE=(237,127,16)
- liste3 = []
- liste4 = []
- i=eval(input(" taille du tableau (doit etre un entier strictement supérieur à 5 ):"))
- while i<5 :
- i=eval(input(" taille du tableau (doit etre un entier strictement supérieur à 5 ) :"))
- m=eval(input("nombre d'atomes :"))
- while m<2 or m>10:
- m=eval(input("nombre d'atomes :"))
- maSurface=pygame.display.set_mode((1400,800))
- #maSurface.fill(RED)
- pygame.display.set_caption('Black box')
- pygame.draw.rect(maSurface,BLUE,(900,55,400,695))
- #recommencer
- fontObj = pygame.font.Font('freesansbold.ttf',30)
- texteSurface = fontObj.render('RECOMMENCER',True,WHITE,BLACK)
- texteRect = texteSurface.get_rect()
- texteRect.topleft = (1000,150)
- if 5<i<10 :
- for x in range (1,i+1):
- for y in range (1,i+1):
- pygame.draw.rect(maSurface,GRIS,(x*65+150,y*65+55,60,60))
- for x in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,(x*65+150,y*65+120,60,60))# ligne du bas
- for x in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,(x*65+150,55,60,60))#ligne du haut
- for y in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,((i+1)*65+150,y*65+55,60,60))# ligne droit
- for y in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,(0+150,y*65+55,60,60))# ligne gauche
- if 15>i>=10 :
- for x in range (1,i+1):
- for y in range (1,i+1):
- pygame.draw.rect(maSurface,GRIS,(x*45+150,y*45+55,40,40))
- for x in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,(x*45+150,y*45+100,40,40))# ligne du bas
- pygame.draw.rect(maSurface,BLUE,(x*45+150,55,40,40))#ligne du haut
- for y in range (1,i+1):
- pygame.draw.rect(maSurface,BLUE,((i+1)*45+150,y*45+55,40,40))# ligne droit
- pygame.draw.rect(maSurface,BLUE,(0+150,y*45+55,40,40))# ligne gauche
- #création des jetons à l'intérieur de celle des cases pour qu'elles s'adaptent aux cases
- if i>=10:
- for j in range (0,m):
- x= random.randint(1,i)
- while x in liste3:
- x= random.randint(1,i)
- liste3.append(x)
- while y in liste4:
- y=random.randint(1,i)
- liste4.append(y)
- pygame.draw.ellipse(maSurface,RED,(x*45+150,y*45+55,30,30))
- else:
- for j in range (0,m):
- while x in liste3:
- x= random.randint(1,i)
- liste3.append(x)
- while y in liste4:
- y= random.randint(1,i)
- liste4.append(y)
- pygame.draw.ellipse(maSurface,RED,(x*65+150,y*65+55,60,60))
- print("end")
- while True:
- for event in pygame.event.get():
- if event.type == QUIT:
- pygame.quit()
- sys.exit()
- pygame.display.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement