R Scott
0
Q:

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()
      
5
Pygame is a good choice for creating GUI and game dev.
Install:
Windows:
pip install pygame
1
python3 -m pip install -U pygame --user
0
import pygame
1
# Pygame basics
# Type pip install pygame on your cmd or powershell
# If your on mac on your terminal type pip3 install pygame

# Why pip3 on mac?

"""
Pip 3 on mac because mac already has Python 2 installed so if you type pip on your terminal in mac
it will install it for python 2 so that is why you have to type in pip3 instead of pip on mac"""

"""
Pygame is a module that you need to install on your cmd or terminal or powershell 
and is used for making 2D arcade games"""

import pygame

# Initialize the pygame module

pygame.init()

# Mainloop of the game

running = True

while running:
  # screen
	screen = pygame.display.set_mode((800, 600))
    
    # Events
    
    for event in pygame.event.get():
      if event.type == pygamw.QUIT:
        running = False
        pygame.quit()
        
-2

New to Communities?

Join the community