turn pixel on display screen python

Solutions on MaxInterview for turn pixel on display screen python by the best coders in the world

showing results for - "turn pixel on display screen python"
Yoann
28 Jun 2018
1# Used this for pygame project just for the entry
2# turn a specific pixel into another colour on your self made game display
3						
4change_specific_pixel =  game_Display.set_at((x, y), (255, 255, 255))
5											# coords	RGB
6  
7# e.g. a random star background for a game
8import random
9starlist = []
10for x in range(1, display_width + 1): # iterates all integers between 1 and max width
11  for y in range(1, display_height + 1): # ditto with max height
12    x = random.randint(1 display_width) # sets random integer to x 
13	y = random.randint(1, display_height) # ditto to y
14    star = game_Display.set_at((x, y), (255,255,255)) # turns pixel on the position (by cord above) into white
15    starlist.append(star) # adds the star to the list above
16    if len(starlist) >= 30:
17      break # loop ends when 30 stars are saved in the list
18#Note: every time the game gets started you'll get a new star formation
19#Sensensven