import pygame, sys #import librerie # Definisco colori in base a convenzione RGB BLACK = (0, 0, 0); WHITE = (255, 255, 255); BLUE = (0, 0, 255) GREEN = (0, 255, 0); RED = (255, 0, 0) pygame.init() # inizializzo pygame # Definisco la grandezza dello schermo size = (600, 400); screen = pygame.display.set_mode(size) pygame.display.set_caption("My First Game with PyGame") # Definisco variabile per comando while done = True rect_x = 50 # -------- Loop Iterativo del while ----------- while done: for event in pygame.event.get(): if event.type == pygame.QUIT: sys.exit(0) # fine programma se utente chiude finestra # Disegno schermo di bianco screen.fill(WHITE) # Disegno rettangolo rosso pygame.draw.rect(screen, RED, [350, 90, 120, 235]) # Disegno una ellisse pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2) # Disegno una linea pygame.draw.line(screen, GREEN, [5, 200], [300, 300], 5) #Disegno un rettangolo che si muove nello schermo in orizzontale pygame.draw.rect(screen, BLUE, [rect_x, 300, 50, 50]) rect_x += 1 # Mostro quanto disegnato fin qui pygame.display.flip() pygame.quit()