diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-15 09:53:06 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-06-15 09:53:06 +0200 |
commit | 532454ebada0ca776e8136450ed8810bc22d210b (patch) | |
tree | 571f6b8b4414797c86f5bf3847a1ebf0fe35ed2f /run.py | |
parent | d8ab67c745b78d0b2f5896cf6642004b3951433c (diff) | |
download | MusicSampler-532454ebada0ca776e8136450ed8810bc22d210b.tar.gz MusicSampler-532454ebada0ca776e8136450ed8810bc22d210b.tar.zst MusicSampler-532454ebada0ca776e8136450ed8810bc22d210b.zip |
Move files
Diffstat (limited to 'run.py')
-rw-r--r-- | run.py | 59 |
1 files changed, 0 insertions, 59 deletions
@@ -1,59 +0,0 @@ | |||
1 | import sys | ||
2 | |||
3 | if getattr(sys, 'frozen', False): | ||
4 | os.chdir(sys._MEIPASS) | ||
5 | |||
6 | import pygame | ||
7 | import pydub | ||
8 | import helpers | ||
9 | |||
10 | pygame.mixer.pre_init(frequency = 44100) | ||
11 | pygame.init() | ||
12 | |||
13 | size = width, height = 1024, 600 | ||
14 | |||
15 | screen = pygame.display.set_mode(size) | ||
16 | background = pygame.Surface(screen.get_size()) | ||
17 | background = background.convert() | ||
18 | background.fill((250, 250, 250)) | ||
19 | |||
20 | action_surface = pygame.Surface((600, 250)).convert() | ||
21 | action_surface.fill((0,0,0)) | ||
22 | helpers.parse_config() | ||
23 | |||
24 | for key_name in helpers.Mapping.KEYS: | ||
25 | key = helpers.Mapping.KEYS[key_name] | ||
26 | key.draw(background) | ||
27 | |||
28 | screen.blit(background, (0, 0)) | ||
29 | screen.blit(action_surface, (10, 330)) | ||
30 | |||
31 | pygame.display.flip() | ||
32 | |||
33 | contexts = [ | ||
34 | 'normal' | ||
35 | ] | ||
36 | |||
37 | context = 'normal' | ||
38 | |||
39 | while 1: | ||
40 | event = pygame.event.wait() | ||
41 | if event.type == pygame.QUIT or ( | ||
42 | event.type == pygame.KEYDOWN and | ||
43 | event.mod == 4160 and | ||
44 | event.key == pygame.K_c): | ||
45 | pygame.quit() | ||
46 | sys.exit() | ||
47 | |||
48 | if context == 'normal': | ||
49 | if event.type == pygame.KEYDOWN: | ||
50 | key = helpers.Key.find_by_key_num(event.key) | ||
51 | if key is not None: | ||
52 | key.do_actions() | ||
53 | elif event.type == pygame.MOUSEBUTTONUP: | ||
54 | key = helpers.Key.find_by_collidepoint(pygame.mouse.get_pos()) | ||
55 | if key is not None: | ||
56 | key.list_actions(action_surface) | ||
57 | |||
58 | pygame.display.flip() | ||
59 | |||