turn pixel display python code example
Example: turn pixel on display screen python
# Used this for pygame project just for the entry
# turn a specific pixel into another colour on your self made game display
change_specific_pixel = game_Display.set_at((x, y), (255, 255, 255))
# coords RGB
# e.g. a random star background for a game
import random
starlist = []
for x in range(1, display_width + 1): # iterates all integers between 1 and max width
for y in range(1, display_height + 1): # ditto with max height
x = random.randint(1 display_width) # sets random integer to x
y = random.randint(1, display_height) # ditto to y
star = game_Display.set_at((x, y), (255,255,255)) # turns pixel on the position (by cord above) into white
starlist.append(star) # adds the star to the list above
if len(starlist) >= 30:
break # loop ends when 30 stars are saved in the list
#Note: every time the game gets started you'll get a new star formation
#Sensensven