made it work

This commit is contained in:
2023-02-18 22:33:32 -05:00
parent dddb0ca6e6
commit 1c7a70ecdc

53
colors/main.py Normal file
View File

@@ -0,0 +1,53 @@
import time
import pygame
def game():
"""
Starts the game.
"""
pygame.init()
# Hide the cursor for the Pi display.
pygame.mouse.set_visible(False)
# The game is normally rendered at 80 pixels and upscaled from there. If changing displays, change the
# screen_size to reflect what the resolution of the new display is.
screen_size = 700
window = pygame.display.set_mode((screen_size, screen_size))
surface = pygame.Surface((screen_size, screen_size))
clock = pygame.time.Clock()
def draw():
"""
Draws the main pygame display.
"""
# Draws all the sprites on screen and scales the screen to the correct size from the rendered size.
frame = pygame.transform.scale(surface, (screen_size, screen_size))
window.blit(frame, frame.get_rect())
# Update the entire display.
pygame.display.flip()
window.fill((255, 0, 0))
pygame.display.flip()
time.sleep(0.5)
window.fill((0, 255, 0))
pygame.display.flip()
time.sleep(0.5)
window.fill((0, 0, 255))
pygame.display.flip()
time.sleep(0.5)
window.fill((255, 255, 255))
pygame.display.flip()
time.sleep(0.5)
window.fill((0, 0, 0))
pygame.display.flip()
time.sleep(0.5)
pygame.quit()
game()