5 # somebody should probably check the randrange()s...
8 from random
import randrange
16 if curses
.has_colors():
18 color
= curses
.color_pair(z
)
20 color
= color | curses
.A_BOLD
26 # we know that the first argument from curses.wrapper() is stdscr.
27 # Initialize it globally for convenience.
31 if curses
.has_colors():
32 bg
= curses
.COLOR_BLACK
33 curses
.init_pair(1, curses
.COLOR_BLUE
, bg
)
34 curses
.init_pair(2, curses
.COLOR_CYAN
, bg
)
38 # XXX curs_set() always returns ERR
46 for j
in range(4, -1, -1):
47 xpos
[j
] = randrange(0, c
) + 2
48 ypos
[j
] = randrange(0, r
) + 2
52 x
= randrange(0, c
) + 2
53 y
= randrange(0, r
) + 2
55 stdscr
.addch(y
, x
, ord('.'))
57 stdscr
.addch(ypos
[j
], xpos
[j
], ord('o'))
60 stdscr
.addch(ypos
[j
], xpos
[j
], ord('O'))
63 stdscr
.addch( ypos
[j
] - 1, xpos
[j
], ord('-'))
64 stdscr
.addstr(ypos
[j
], xpos
[j
] - 1, "|.|")
65 stdscr
.addch( ypos
[j
] + 1, xpos
[j
], ord('-'))
68 stdscr
.addch( ypos
[j
] - 2, xpos
[j
], ord('-'))
69 stdscr
.addstr(ypos
[j
] - 1, xpos
[j
] - 1, "/ \\")
70 stdscr
.addstr(ypos
[j
], xpos
[j
] - 2, "| O |")
71 stdscr
.addstr(ypos
[j
] + 1, xpos
[j
] - 1, "\\ /")
72 stdscr
.addch( ypos
[j
] + 2, xpos
[j
], ord('-'))
75 stdscr
.addch( ypos
[j
] - 2, xpos
[j
], ord(' '))
76 stdscr
.addstr(ypos
[j
] - 1, xpos
[j
] - 1, " ")
77 stdscr
.addstr(ypos
[j
], xpos
[j
] - 2, " ")
78 stdscr
.addstr(ypos
[j
] + 1, xpos
[j
] - 1, " ")
79 stdscr
.addch( ypos
[j
] + 2, xpos
[j
], ord(' '))
85 if ch
== ord('q') or ch
== ord('Q'):