diff options
Diffstat (limited to 'run.py')
-rw-r--r-- | run.py | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -0,0 +1,45 @@ | |||
1 | import pygame | ||
2 | import sys | ||
3 | import helpers | ||
4 | |||
5 | pygame.init() | ||
6 | |||
7 | size = width, height = 1024, 600 | ||
8 | |||
9 | screen = pygame.display.set_mode(size) | ||
10 | background = pygame.Surface(screen.get_size()) | ||
11 | background = background.convert() | ||
12 | background.fill((250, 250, 250)) | ||
13 | |||
14 | for key_name in helpers.keys: | ||
15 | key = helpers.keys[key_name] | ||
16 | key.draw(background) | ||
17 | |||
18 | screen.blit(background, (0, 0)) | ||
19 | pygame.display.flip() | ||
20 | |||
21 | contexts = [ | ||
22 | 'normal' | ||
23 | ] | ||
24 | |||
25 | context = 'normal' | ||
26 | |||
27 | while 1: | ||
28 | event = pygame.event.wait() | ||
29 | if event.type == pygame.QUIT or ( | ||
30 | event.type == pygame.KEYDOWN and | ||
31 | event.mod == 4160 and | ||
32 | event.key == pygame.K_c): | ||
33 | pygame.quit() | ||
34 | sys.exit() | ||
35 | |||
36 | if context == 'normal': | ||
37 | if event.type == pygame.KEYDOWN and event.key in helpers.keys: | ||
38 | helpers.keys[event.key].do_actions() | ||
39 | if event.type == pygame.MOUSEBUTTONUP: | ||
40 | for key in helpers.keys: | ||
41 | if helpers.keys[key].collidepoint(pygame.mouse.get_pos()): | ||
42 | helpers.keys[key].do_actions() | ||
43 | |||
44 | pygame.display.flip() | ||
45 | |||