-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkm_old.py
50 lines (40 loc) · 932 Bytes
/
km_old.py
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
46
47
48
49
50
from hw import *
from ion import *
#from grid import Grid
KEYS_PRESSED={}
LAST_KEYS={}
def updKey(key):
global KEYS_PRESSED
if keydown(key):
KEYS_PRESSED|={key}
else:
KEYS_PRESSED-={key}
def keyon(key):
"""
if key in KEYS_PRESSED and not keydown(key):
KEYS_PRESSED-={key}
print("rm")
if (not key in KEYS_PRESSED) and keydown(key):
KEYS_PRESSED|={key}
print("ad")
"""
#updKey(key)
global KEYS_PRESSED
KEYS_PRESSED[key]=keydown(key)
return keydown(key)
def keyin(key):
#print(key not in KEYS_PRESSED,keydown(key))
out=key not in KEYS_PRESSED and keyon(key)
keyon(key)
return out
def keyout(key):
out = key in KEYS_PRESSED and not keyon(key)
keyon(key)
return out
"""
while True:
#print(KEYS_PRESSED,keyin(KEY_RIGHT),keyout(KEY_RIGHT))
for e,event in enumerate([keyin,keyon,keyout]):
if event(KEY_RIGHT):
print(["in","on","out"][e])
"""