how to set up 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: intall pygame
python3 -m pip install -U pygame --user
Wha?
Example 3: 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 4: install pygame
pip install pygame
Example 5: how to set up pygame
import pygame
import os
import sys
import random
pygame.init()
screen = pygame.display.set_mode((800, 500))