-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplosion.py
44 lines (38 loc) · 867 Bytes
/
explosion.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
import asyncio
import curses
from curses_tools import draw_frame, get_frame_size
EXPLOSION_FRAMES = [
"""\
(_)
( ( ( (
() ( ( )
( ) ()
""",
"""\
(_)
( ( (
( ( )
) (
""",
"""\
(
( (
( (
) (
""",
"""\
(
(
(
""",
]
async def explode(canvas, center_row, center_column):
rows, columns = get_frame_size(EXPLOSION_FRAMES[0])
corner_row = center_row - rows / 2
corner_column = center_column - columns / 2
curses.beep()
for frame in EXPLOSION_FRAMES:
draw_frame(canvas, corner_row, corner_column, frame)
await asyncio.sleep(0)
draw_frame(canvas, corner_row, corner_column, frame, negative=True)
await asyncio.sleep(0)