forked from libtcod/python-tcod
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheventget_tcod.py
More file actions
26 lines (22 loc) · 879 Bytes
/
Copy patheventget_tcod.py
File metadata and controls
26 lines (22 loc) · 879 Bytes
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
#!/usr/bin/env python
import tcod
WIDTH, HEIGHT = 80, 60
key = tcod.Key()
mouse = tcod.Mouse()
with tcod.console_init_root(WIDTH, HEIGHT, 'tcod events example') as console:
tcod.sys_set_fps(24)
while not tcod.console_is_window_closed():
ev = tcod.sys_wait_for_event(tcod.EVENT_ANY, key, mouse, False)
if ev & tcod.EVENT_KEY:
console.blit(console, 0, 0, 0, 1, WIDTH, HEIGHT - 2)
console.print_(0, HEIGHT - 3, repr(key))
print(key)
if ev & tcod.EVENT_MOUSE_MOVE:
console.rect(0, HEIGHT - 1, WIDTH, 1, True)
console.print_(0, HEIGHT - 1, repr(mouse))
print(mouse)
elif ev & tcod.EVENT_MOUSE:
console.blit(console, 0, 0, 0, 1, WIDTH, HEIGHT - 2)
console.print_(0, HEIGHT - 3, repr(mouse))
print(mouse)
tcod.console_flush()