Skip to content

Instantly share code, notes, and snippets.

@IanMcT
Created December 6, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanMcT/2c4811f5653b8e5795146d4ebfbb73b8 to your computer and use it in GitHub Desktop.
Save IanMcT/2c4811f5653b8e5795146d4ebfbb73b8 to your computer and use it in GitHub Desktop.
This shows how to create a screen in pygame.
#!/usr/bin/env python
import random, os.path
#import basic pygame modules
import pygame
from pygame.locals import *
SCREENRECT = Rect(0, 0, 640, 480)
GAME_ON = True
def main(winstyle = 0):
# Initialize pygame
pygame.init()
# Set the display mode
winstyle = 0 # |FULLSCREEN
bestdepth = pygame.display.mode_ok(SCREENRECT.size, winstyle, 32)
screen = pygame.display.set_mode(SCREENRECT.size, winstyle, bestdepth)
while GAME_ON:
#get input
for event in pygame.event.get():
if event.type == QUIT or \
(event.type == KEYDOWN and event.key == K_ESCAPE):
return
keystate = pygame.key.get_pressed()
#call the "main" function if running this script
if __name__ == '__main__': main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment