]>
Commit | Line | Data |
---|---|---|
189bf90c | 1 | import pygame |
8f88a3e4 | 2 | import pydub |
189bf90c IB |
3 | import sys |
4 | import helpers | |
5 | ||
8f88a3e4 | 6 | pygame.mixer.pre_init(frequency = 44100) |
189bf90c IB |
7 | pygame.init() |
8 | ||
9 | size = width, height = 1024, 600 | |
10 | ||
11 | screen = pygame.display.set_mode(size) | |
12 | background = pygame.Surface(screen.get_size()) | |
13 | background = background.convert() | |
14 | background.fill((250, 250, 250)) | |
15 | ||
8f88a3e4 IB |
16 | helpers.parse_config() |
17 | ||
18 | for key_name in helpers.Mapping.KEYS: | |
19 | key = helpers.Mapping.KEYS[key_name] | |
189bf90c IB |
20 | key.draw(background) |
21 | ||
22 | screen.blit(background, (0, 0)) | |
23 | pygame.display.flip() | |
24 | ||
25 | contexts = [ | |
26 | 'normal' | |
27 | ] | |
28 | ||
29 | context = 'normal' | |
30 | ||
31 | while 1: | |
32 | event = pygame.event.wait() | |
33 | if event.type == pygame.QUIT or ( | |
34 | event.type == pygame.KEYDOWN and | |
35 | event.mod == 4160 and | |
36 | event.key == pygame.K_c): | |
37 | pygame.quit() | |
38 | sys.exit() | |
39 | ||
40 | if context == 'normal': | |
8f88a3e4 IB |
41 | if event.type == pygame.KEYDOWN and event.key in helpers.Mapping.KEYS: |
42 | helpers.Mapping.KEYS[event.key].do_actions() | |
189bf90c | 43 | if event.type == pygame.MOUSEBUTTONUP: |
8f88a3e4 IB |
44 | for key in helpers.Mapping.KEYS: |
45 | if helpers.Mapping.KEYS[key].collidepoint(pygame.mouse.get_pos()): | |
46 | helpers.Mapping.KEYS[key].do_actions() | |
189bf90c IB |
47 | |
48 | pygame.display.flip() | |
49 |