Created
August 15, 2017 18:51
-
-
Save natebot13/bd8fba5084aa77273cf5a08b4355dc39 to your computer and use it in GitHub Desktop.
Pygame Basic Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
# initialize game engine | |
pygame.init() | |
# set screen width/height and caption | |
WIDTH = 640 | |
HEIGHT = 480 | |
SIZE = (WIDTH, HEIGHT) | |
screen = pygame.display.set_mode(SIZE) | |
pygame.display.set_caption('My Game') | |
# initialize clock. used later in the loop. | |
CLOCK = pygame.time.Clock() | |
FPS = 60 | |
# Loop until the user clicks close button | |
running = True | |
while running: | |
# write event handlers here | |
for event in pygame.event.get(): | |
if event.type == pygame.QUIT: | |
running = False | |
# write game logic here | |
# clear the screen before drawing | |
screen.fill((255, 255, 255)) | |
# write draw code here | |
# display what’s drawn. this might change. | |
pygame.display.update() | |
# run at 20 fps | |
CLOCK.tick(FPS) | |
# close the window and quit | |
pygame.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment