beautification: user nicer ascii chars to draw the box

master
panki27 7 years ago
parent 41bc6c2821
commit 9f37f76db8

@ -1,5 +1,5 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
#TODO: show controls, restartable, command line flags like "easy, hard" #TODO: restartable, highscore (?)
import random, io, sys, time, os import random, io, sys, time, os
@ -87,17 +87,22 @@ playfield = [[UNKNOWN for x in range(width)] for y in range(height)]
#stdscr = curses.initscr() #stdscr = curses.initscr()
#curses.noecho() #curses.noecho()
#curses.cbreak() #curses.cbreak()
headline = '.' headline = ''
midline = '|' midline = '├'
tailline = '\'' tailline = ''
def setup_strings(colcount): def setup_strings(colcount):
#setup lines to print #setup lines to print
for i in range(colcount):
global headline, midline, tailline global headline, midline, tailline
headline += '---.' for i in range(colcount):
midline += '---|' if i == width-1:
tailline += '---\'' headline += '───┐'
midline += '───┤'
tailline += '───┘'
else:
headline += '───┬'
midline += '───┼'
tailline += '───┴'
def endgame(msg=''): def endgame(msg=''):
# curses.nocbreak() # curses.nocbreak()
@ -193,7 +198,7 @@ def print_playfield(playfield, screen):
currentline +=1 currentline +=1
#print headline #print headline
for rowindex, row in enumerate(playfield): for rowindex, row in enumerate(playfield):
screen.addstr(currentline, 10, '|') screen.addstr(currentline, 10, '')
pos = OFFSET pos = OFFSET
for colindex, cell in enumerate(row): for colindex, cell in enumerate(row):
# is the cell selected? # is the cell selected?
@ -220,9 +225,9 @@ def print_playfield(playfield, screen):
# rowstring += 'X' # rowstring += 'X'
pos += 1 pos += 1
if selected: if selected:
screen.addstr(currentline, pos, ']|') screen.addstr(currentline, pos, ']')
else: else:
screen.addstr(currentline, pos, ' |') screen.addstr(currentline, pos, ' ')
pos += 2 pos += 2
currentline +=1 currentline +=1
if(rowindex < len(row)-1): if(rowindex < len(row)-1):

Loading…
Cancel
Save