how to install pygame in python
pip install pygame
python pygame
# Be sure to install pygame via pip
import pygame
import sys
# initialize it
pygame.init()
# configurations
frames_per_second = 30
window_height = 600
window_width = 400
# colors
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
BLUE = (0, 0, 255)
# creating window
display = pygame.display.set_mode((window_width, window_height))
# creating our frame regulator
clock = pygame.time.Clock()
# forever loop
while True:
# frame clock ticking
clock.tick(frames_per_second)
# frame Drawing
display.fill(WHITE)
# event loop
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
pygame python
# Pygame boiler plate
# Should have a red square on screen if run
# pip3 install pygame
import pygame
screen = pygame.display.set_mode((1280, 720))
running = True
while running:
screen.fill((0, 0, 0))
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.draw.rect(screen, (255, 0, 0), ((10, 10), (50, 50)))
pygame.display.update()
pygame.quit()
how to import pygame
# Type this in the Command Prompt (For Windows) : pip install pygame
# Then head on to your text editor and type :
import pygame
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us