pypy pygame code example

Example 1: install pygame

# on your terminal : 
pip install pygame 

# check if pygame run : 
py -m pygame.examples.aliens 
# if a window is open -> pygame is correctly installed

Example 2: 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()

Example 3: pygame

Pygame is a good choice for creating GUI and game dev.
Install:
Windows:
pip install pygame

Example 4: pygame

python -m pip install -U pip