]>
Commit | Line | Data |
---|---|---|
d8ab67c7 | 1 | import sys |
189bf90c | 2 | import pygame |
189bf90c | 3 | import helpers |
e7f8dab4 | 4 | import threading |
189bf90c | 5 | |
8f88a3e4 | 6 | pygame.mixer.pre_init(frequency = 44100) |
189bf90c IB |
7 | pygame.init() |
8 | ||
9 | size = width, height = 1024, 600 | |
10 | ||
e7f8dab4 | 11 | helpers.draw_lock.acquire() |
189bf90c | 12 | screen = pygame.display.set_mode(size) |
e7f8dab4 | 13 | mapping = helpers.Mapping(screen) |
189bf90c | 14 | |
d8ab67c7 IB |
15 | action_surface = pygame.Surface((600, 250)).convert() |
16 | action_surface.fill((0,0,0)) | |
e7f8dab4 IB |
17 | helpers.parse_config(mapping) |
18 | helpers.draw_lock.release() | |
8f88a3e4 | 19 | |
e7f8dab4 | 20 | mapping.draw() |
189bf90c | 21 | |
e7f8dab4 | 22 | helpers.draw_lock.acquire() |
d8ab67c7 IB |
23 | screen.blit(action_surface, (10, 330)) |
24 | ||
189bf90c | 25 | pygame.display.flip() |
e7f8dab4 | 26 | helpers.draw_lock.release() |
189bf90c IB |
27 | |
28 | contexts = [ | |
29 | 'normal' | |
30 | ] | |
31 | ||
32 | context = 'normal' | |
33 | ||
34 | while 1: | |
35 | event = pygame.event.wait() | |
e7f8dab4 | 36 | |
189bf90c IB |
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 | 45 | if event.type == pygame.KEYDOWN: |
e7f8dab4 | 46 | key = mapping.find_by_key_num(event.key) |
d8ab67c7 | 47 | if key is not None: |
e7f8dab4 | 48 | threading.Thread(target=key.do_actions).start() |
d8ab67c7 | 49 | elif event.type == pygame.MOUSEBUTTONUP: |
e7f8dab4 | 50 | key = mapping.find_by_collidepoint(pygame.mouse.get_pos()) |
d8ab67c7 IB |
51 | if key is not None: |
52 | key.list_actions(action_surface) | |
189bf90c IB |
53 | |
54 | pygame.display.flip() | |
55 |