how to setup pygame code example
Example 1: how to setup pygame
import pygame
import sys
pygame.init()
clock = pygame.time.Clock()
FPS = 30
screen_width = 600
screen_height = 600
screen = pygame.display.set_mode((screen_width, screen_height))
while True:
clock.tick(FPS)
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
Example 2: install pygame on mac
python3 -m pip install -U pygame==2.0.0.dev6
Example 3: how to download pygame on mac
pip download pygame
Example 4: pip install pygame
py -m pip install -U pygame --user
Example 5: pygame setup
import pygame
pygame.init()
win = pygame.display.set_mode((500,500))
pygame.display.set_caption("First Game")
x = 50
y = 50
width = 40
height = 60
vel = 5
run = True
while run:
pygame.time.delay(100)
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
pygame.quit()
Example 6: install pygame
pip install pygame