import random, os.path import util import pygame import pygame.font from pygame.locals import * def run(): #Must initialize pygame before doing anything else pygame.init() random.seed() display_flags = DOUBLEBUF #XO laptop is 1200x900 resolution width, height = 1200, 900 if pygame.display.mode_ok((width, height), display_flags ): screen = pygame.display.set_mode((width, height), display_flags) clock = pygame.time.Clock() run = 1 pygame.display.set_caption('OLPC Math Game') while run: events = pygame.event.get() for event in events: #User decides to exit program if event.type == QUIT: run = 0 #stop running pygame.quit() pygame.display.flip() clock.tick(40) #limits to 40 FPS def main(): run() #runs main if called via other naming convention if __name__ == '__main__': main()