Update terminis.py
This commit is contained in:
parent
71037c6182
commit
e6d18deb9b
@ -62,53 +62,6 @@ class Movement:
|
||||
STILL = Point(0, 0)
|
||||
|
||||
|
||||
class Screen:
|
||||
|
||||
def __enter__(self):
|
||||
self.scr = curses.initscr()
|
||||
curses.def_shell_mode()
|
||||
if curses.has_colors():
|
||||
self.init_colors()
|
||||
curses.noecho()
|
||||
curses.cbreak()
|
||||
self.scr.keypad(True)
|
||||
curses.curs_set(0)
|
||||
self.scr.clear()
|
||||
self.scr.nodelay(True)
|
||||
self.scr.leaveok(True)
|
||||
self.scr.getch()
|
||||
return self.scr
|
||||
if curses.has_colors():
|
||||
self.init_colors()
|
||||
|
||||
def init_colors(self):
|
||||
curses.start_color()
|
||||
if curses.COLORS >= 16:
|
||||
if curses.can_change_color():
|
||||
curses.init_color(curses.COLOR_YELLOW, 1000, 500, 0)
|
||||
curses.init_pair(Color.ORANGE, curses.COLOR_YELLOW, curses.COLOR_YELLOW)
|
||||
curses.init_pair(Color.RED, curses.COLOR_RED+8, curses.COLOR_RED+8)
|
||||
curses.init_pair(Color.GREEN, curses.COLOR_GREEN+8, curses.COLOR_GREEN+8)
|
||||
curses.init_pair(Color.YELLOW, curses.COLOR_YELLOW+8, curses.COLOR_YELLOW+8)
|
||||
curses.init_pair(Color.BLUE, curses.COLOR_BLUE+8, curses.COLOR_BLUE+8)
|
||||
curses.init_pair(Color.MAGENTA, curses.COLOR_MAGENTA+8, curses.COLOR_MAGENTA+8)
|
||||
curses.init_pair(Color.CYAN, curses.COLOR_CYAN+8, curses.COLOR_CYAN+8)
|
||||
curses.init_pair(Color.WHITE, curses.COLOR_WHITE+8, curses.COLOR_WHITE+8)
|
||||
else:
|
||||
curses.init_pair(Color.ORANGE, curses.COLOR_YELLOW, curses.COLOR_YELLOW)
|
||||
curses.init_pair(Color.RED, curses.COLOR_RED, curses.COLOR_RED)
|
||||
curses.init_pair(Color.GREEN, curses.COLOR_GREEN, curses.COLOR_GREEN)
|
||||
curses.init_pair(Color.YELLOW, curses.COLOR_WHITE, curses.COLOR_WHITE)
|
||||
curses.init_pair(Color.BLUE, curses.COLOR_BLUE, curses.COLOR_BLUE)
|
||||
curses.init_pair(Color.MAGENTA, curses.COLOR_MAGENTA, curses.COLOR_MAGENTA)
|
||||
curses.init_pair(Color.CYAN, curses.COLOR_CYAN, curses.COLOR_CYAN)
|
||||
curses.init_pair(Color.WHITE, curses.COLOR_WHITE, curses.COLOR_WHITE)
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
curses.reset_shell_mode()
|
||||
curses.endwin()
|
||||
|
||||
|
||||
class Mino:
|
||||
def __init__(self, position, color):
|
||||
self.position = position
|
||||
@ -351,9 +304,9 @@ class Matrix(Window):
|
||||
self.window.addstr(11, 9, "PAUSE", curses.A_BOLD)
|
||||
else:
|
||||
for y, line in enumerate(self.cells):
|
||||
for x, mino in enumerate(line):
|
||||
if mino:
|
||||
self.draw_mino(x, y, mino.color)
|
||||
for x, color in enumerate(line):
|
||||
if color:
|
||||
self.draw_mino(x, y, color)
|
||||
self.draw_piece()
|
||||
self.window.refresh()
|
||||
|
||||
@ -368,7 +321,7 @@ class Matrix(Window):
|
||||
for mino in self.piece.minoes:
|
||||
position = mino.position + self.piece.position
|
||||
if position.y >= 0:
|
||||
self.cells[position.y][position.x] = mino
|
||||
self.cells[position.y][position.x] = mino.color
|
||||
nb_lines_cleared = 0
|
||||
for y, line in enumerate(self.cells):
|
||||
if all(mino for mino in line):
|
||||
|
Loading…
x
Reference in New Issue
Block a user