Hey I have created a small program in pygame to just create noise (white and black pixels) and repeatedly replace over itself with more noise:
import pygame
import random
WIDTH = 1920
HIGHT = 1080
pygame.init()
screen = pygame.display.set_mode((WIDTH,HIGHT))
pygame.display.set_caption("Noise.py")
def update():
for y in range(HIGHT):
for x in range (WIDTH):
pygame.event.get()
num = random.randint(0,1)
color = (0 ,0 ,0 ) if num == 1 else (255,255,255)
screen.set_at((x, y), color)
pygame.display.update()
def main ():
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
update()
main()
The program works tough it is too slow to create the effect that I wanted (run at 30 to 60 fps). The only way I can for now make if a bit faster is by dropping the resolution though I would prefer not to.
Is there a way to assign individual pixel color in pygame faster? or even mabe a better way of going about this?