]>
Commit | Line | Data |
---|---|---|
d8ab67c7 | 1 | import sys |
189bf90c | 2 | import pygame |
8f88a3e4 | 3 | import pydub |
189bf90c IB |
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 | ||
d8ab67c7 IB |
16 | action_surface = pygame.Surface((600, 250)).convert() |
17 | action_surface.fill((0,0,0)) | |
8f88a3e4 IB |
18 | helpers.parse_config() |
19 | ||
20 | for key_name in helpers.Mapping.KEYS: | |
21 | key = helpers.Mapping.KEYS[key_name] | |
189bf90c IB |
22 | key.draw(background) |
23 | ||
24 | screen.blit(background, (0, 0)) | |
d8ab67c7 IB |
25 | screen.blit(action_surface, (10, 330)) |
26 | ||
189bf90c IB |
27 | pygame.display.flip() |
28 | ||
29 | contexts = [ | |
30 | 'normal' | |
31 | ] | |
32 | ||
33 | context = 'normal' | |
34 | ||
35 | while 1: | |
36 | event = pygame.event.wait() | |
37 | if event.type == pygame.QUIT or ( | |
38 | event.type == pygame.KEYDOWN and | |
39 | event.mod == 4160 and | |
40 | event.key == pygame.K_c): | |
41 | pygame.quit() | |
42 | sys.exit() | |
43 | ||
44 | if context == 'normal': | |
d8ab67c7 IB |
45 | if event.type == pygame.KEYDOWN: |
46 | key = helpers.Key.find_by_key_num(event.key) | |
47 | if key is not None: | |
48 | key.do_actions() | |
49 | elif event.type == pygame.MOUSEBUTTONUP: | |
50 | key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos()) | |
51 | if key is not None: | |
52 | key.list_actions(action_surface) | |
189bf90c IB |
53 | |
54 | pygame.display.flip() | |
55 |