Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Last active August 11, 2021 16:35
Show Gist options
  • Save cbscribe/9ce2e6cd40be079a0257e9fc1650d2e7 to your computer and use it in GitHub Desktop.
Save cbscribe/9ce2e6cd40be079a0257e9fc1650d2e7 to your computer and use it in GitHub Desktop.
Pygame template
import pygame
import random
WIDTH = 800
HEIGHT = 600
FPS = 60
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
clock = pygame.time.Clock()
all_sprites = pygame.sprite.Group()
running = True
while running:
clock.tick(FPS)
# events
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# updates
all_sprites.update()
# draw
screen.fill( (40, 40, 40) )
all_sprites.draw(screen)
pygame.display.flip() # DO THIS LAST!
pygame.quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment