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