#pixels.py # #Plotting pixels on the screen # import pygame import random screen = pygame.display.set_mode((640, 480)) #Pygame screen 640 X 480 pygame.display.set_caption("pygame window") #Pygame window title PIXEL_COLOR = (0, 255, 0) #Green RGB value BG_COLOR = (0, 0, 0) #Black RGB value clock = pygame.time.Clock() #pygame clcok FPS = 60 #60 FPS running = True #Main game loop executes while true while running: #sets a pixel at a random position on screen. The function works #as follows surface.set_at((x, y), pixelColor) x and y being the #position of the pixel on screen and pixelColor being the color #of the pixel x = random.randint(0, 640) y = random.randint(0, 480) screen.set_at((x, y), PIXEL_COLOR) #For loop that checks for pygame events and if the quit event is #found running is set to False for event in pygame.event.get(): if event.type == pygame.QUIT: running = False pygame.display.flip() #Updates display clock.tick(FPS) #Sets the framerate