Created
December 6, 2016 19:41
-
-
Save IanMcT/2c4811f5653b8e5795146d4ebfbb73b8 to your computer and use it in GitHub Desktop.
This shows how to create a screen in pygame.
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
#!/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