Skip to content

Instantly share code, notes, and snippets.

@tyspa1
Created January 10, 2015 16:34
Show Gist options
  • Save tyspa1/3fb2cac0d76abd7ec728 to your computer and use it in GitHub Desktop.
Save tyspa1/3fb2cac0d76abd7ec728 to your computer and use it in GitHub Desktop.
Basis for every pygame program a make
#Basic Pygame
#Every thing you need in a Python/pygame program
#copyright 2015 (c) Tyler Spadgenske GPL 3.0 License
import pygame, sys, os
from pygame.locals import *
pygame.init()
WINDOWWIDTH = 800
WINDOWHIEGHT = 480
os.environ ['SDL_VIDEO_WINDOW_POS'] = 'center'
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHIEGHT), 0, 32)
pygame.display.set_caption('Test')
mainClock = pygame.time.Clock()
BLUE = (0,0,255)
WHITE = (255, 255, 255)
block = {'rect':pygame.Rect(200, 200, 50, 50),'color':BLUE}
windowSurface.fill(WHITE)
pygame.draw.rect(windowSurface, block['color'], block['rect'])
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
mainClock.tick()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment