1import pygame
2pygame.init()
3back = (192,192,192)
4gameDisplay = pygame.display.set_mode((800,600))
5pygame.display.set_caption('A bit Racey')
6gameDisplay.fill(back)
7clock = pygame.time.Clock()
8running = True
9while running:
10 for event in pygame.event.get():
11 if event.type == pygame.QUIT:
12 running = False
13 pygame.display.update()
14 clock.tick(60)
15pygame.quit()
16quit()
17
18
1python3 -m pip install pygame <<<(mac)>>>
2or
3python -m pip install pygame <<<(windows)>>>
4or
5sudo apt install python3-pygame <<<(ubuntu)>>>
1 1 # Simple pygame program
2 2
3 3 # Import and initialize the pygame library
4 4 import pygame
5 5 pygame.init()
6 6
7 7 # Set up the drawing window
8 8 screen = pygame.display.set_mode([500, 500])
9 9
1010 # Run until the user asks to quit
1111 running = True
1212 while running:
1313
1414 # Did the user click the window close button?
1515 for event in pygame.event.get():
1616 if event.type == pygame.QUIT:
1717 running = False
1818
1919 # Fill the background with white
2020 screen.fill((255, 255, 255))
2121
2222 # Draw a solid blue circle in the center
2323 pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)
2424
2525 # Flip the display
2626 pygame.display.flip()
2727
2828 # Done! Time to quit.
2929 pygame.quit()
30
1# Import and initialize the pygame library
2import pygame
3pygame.init()
4
5# Set up the drawing window
6screen = pygame.display.set_mode([500, 500])
7
8# Run until the user asks to quit
9running = True
10while running:
11
12 # Did the user click the window close button?
13 for event in pygame.event.get():
14 if event.type == pygame.QUIT:
15 running = False
16
17 # Fill the background with white
18 screen.fill((255, 255, 255))
19
20 # Draw a solid blue circle in the center
21 pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)
22
23 # Flip the display
24 pygame.display.flip()
25
26# Time to end the Game
27pygame.quit()
28
1# Simple pygame code!
2import pygame
3
4pygame.init() # intialize the library
5
6# Set up the drawing window
7screen = pygame.display.set_mode([500, 500])
8
9# Run until the user asks to quit
10running = True
11while running:
12 # Check if the user clicked the close button so that they dont keep playing for like
13 # 2 years
14 for event in pygame.event.get():
15 if event.type == pygame.QUIT:
16 running = False
17
18 # Fill the background with white (R, G, B) (also if you dont like lightmode, just replace it with (0,0,0))
19 screen.fill((255, 255, 255))
20
21 # Draw a blue circle in the center
22 pygame.draw.circle(screen, (0, 0, 255), (250, 250), 75)
23
24 # Flip the display
25 pygame.display.flip()
26
27# Quit the program
28pygame.quit()