Jun-10-2019, 04:51 AM
I made a block rectangle that is supposed to slowly go from 255 transparency to 0. I am having problems though. I don't understand this because I can slowly make it darken, but I can't get it to slowly lighten. Thanks in Advance. Here is the code -
For lightening it slowly. BTW - the indentations are weird because this is all inside a function.
For lightening it slowly. BTW - the indentations are weird because this is all inside a function.
#Presets interval = time.time() transparency = 255 cover = pygame.Surface((500, 500), pygame.SRCALPHA) #Cover Screen while time.time() - interval < 10: for event in pygame.event.get(): if event.type == pygame.QUIT: interval -= 10 cover.fill((0, 0, 0, transparency)) Screen.blit(cover, (0, 0)) if transparency != 0: transparency -= 1 time.sleep(0.05) pygame.display.update() Clock.tick(fps)That code won't work, but this code for darkening the transparency does work.
#Presets interval = time.time() transparency = 0 cover = pygame.Surface((500, 500), pygame.SRCALPHA) #Cover Screen while time.time() - interval < 10: for event in pygame.event.get(): if event.type == pygame.QUIT: interval -= 10 cover.fill((0, 0, 0, transparency)) Screen.blit(cover, (0, 0)) if transparency != 255: transparency += 1 time.sleep(0.05) pygame.display.update() Clock.tick(fps)