blob: 706d38ee98129e559d4b0a5a8db715c427c99563 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
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()
|