summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2016-02-16 07:41:36 -0800
committerJoe Anderson <jandew+dev@gmail.com>2016-02-16 07:41:36 -0800
commit8f37393fa64995a3aa500079081f5ead66c2a41c (patch)
tree75f397ac22f3c59809135ea41ff6d06cde98058e
parent837dabf3f3e4409922d204cf7e2a962af8ee5156 (diff)
downloadoo-8f37393fa64995a3aa500079081f5ead66c2a41c.tar.gz
oo-8f37393fa64995a3aa500079081f5ead66c2a41c.zip
checkered background, colored help text
-rw-r--r--oo.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/oo.py b/oo.py
index 850a620..8ee61a5 100644
--- a/oo.py
+++ b/oo.py
@@ -238,10 +238,15 @@ class ooPlay:
self.puzzle.random_orients()
self.screen.clear()
+ # set up colors
+ curses.start_color()
+ curses.init_color(curses.COLOR_GREEN, 0, 300, 0)
+ curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_GREEN)
+ curses.init_pair(2, curses.COLOR_RED, curses.COLOR_BLACK)
+ curses.init_pair(3, curses.COLOR_RED, curses.COLOR_GREEN)
+
# draw the help area and board state
self.help_ind = 0
- border_line = self.X * "═"
- self.screen.addstr(self.Y - 2, 0, border_line)
self.write()
self.display()
@@ -262,7 +267,8 @@ class ooPlay:
piece = self.puzzle.pieces [x, y]
orient = self.puzzle.orients[x, y]
string = self.PIECE_ORIENT_TO_STRING[piece][orient]
- self.screen.addstr(y, x, string)
+ color = curses.color_pair((x + y) % 2)
+ self.screen.addstr(y, x, string, color)
self.screen.refresh()
def display(self):
@@ -272,7 +278,8 @@ class ooPlay:
piece = self.puzzle.pieces [x, y]
orient = self.puzzle.orients[x, y]
string = self.PIECE_ORIENT_TO_STRING[piece][orient]
- self.screen.addstr(y, x, string)
+ color = curses.color_pair((x + y) % 2)
+ self.screen.addstr(y, x, string, color)
self.screen.refresh()
pause_length = 80
@@ -298,12 +305,15 @@ class ooPlay:
if pause == None:
pause = True
width = self.X - 1
+ color = curses.color_pair(int(pause))
+ border_line = self.X * "═"
+ self.screen.addstr(self.Y - 2, 0, border_line, color)
# writing a string that fits in the width
if len(string) <= width:
centered_string = string.center(width, " ")
- self.screen.addstr(self.Y - 1, 0, centered_string)
+ self.screen.addstr(self.Y - 1, 0, centered_string, color)
self.screen.refresh()
if pause: curses.napms(2 * self.pause_length * len(string))
curses.ungetch(0) # clear input
@@ -312,11 +322,11 @@ class ooPlay:
# scrolling through a wider string
strings = [string[i:i + width] for i in range(len(string) - width + 1)]
- self.screen.addstr(self.Y - 1, 0, strings[0])
+ self.screen.addstr(self.Y - 1, 0, strings[0], color)
self.screen.refresh()
curses.napms(self.pause_length * width)
for s in strings:
- self.screen.addstr(self.Y - 1, 0, s)
+ self.screen.addstr(self.Y - 1, 0, s, color)
self.screen.refresh()
curses.napms(self.pause_length)
if pause: curses.napms(self.pause_length * width)