Add files via upload

This commit is contained in:
adrienmalin 2019-02-10 13:59:59 +01:00 committed by GitHub
parent ce064c664f
commit 80e790d631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,6 +80,9 @@ class Screen:
self.scr.keypad(True) self.scr.keypad(True)
curses.curs_set(0) curses.curs_set(0)
self.scr.clear() self.scr.clear()
self.scr.nodelay(True)
self.scr.leaveok(True)
self.scr.getch()
return self.scr return self.scr
def init_colors(self): def init_colors(self):
@ -318,12 +321,12 @@ class Window:
def draw_piece(self): def draw_piece(self):
if self.piece: if self.piece:
color = Color.WHITE if self.piece.lock_timer else self.piece.COLOR color = Color.WHITE|curses.A_BLINK if self.piece.lock_timer else self.piece.COLOR
for mino in self.piece.minoes: for mino in self.piece.minoes:
position = mino.position + self.piece.position position = mino.position + self.piece.position
self.show_mino(position.x, position.y, color) self.draw_mino(position.x, position.y, color)
def show_mino(self, x, y, color): def draw_mino(self, x, y, color):
if y >= 0: if y >= 0:
if self.has_colors: if self.has_colors:
self.window.addstr(y, x*2+1, "██", curses.color_pair(color)) self.window.addstr(y, x*2+1, "██", curses.color_pair(color))
@ -357,7 +360,7 @@ class Matrix(Window):
for y, line in enumerate(self.cells): for y, line in enumerate(self.cells):
for x, mino in enumerate(line): for x, mino in enumerate(line):
if mino: if mino:
self.show_mino(x, y, mino.color) self.draw_mino(x, y, mino.color)
self.draw_piece() self.draw_piece()
self.window.refresh() self.window.refresh()
@ -540,7 +543,6 @@ class Game:
side_height = self.HEIGHT - Hold.HEIGHT side_height = self.HEIGHT - Hold.HEIGHT
right_x = left_x + Matrix.WIDTH + side_width right_x = left_x + Matrix.WIDTH + side_width
bottom_y = top_y + Hold.HEIGHT bottom_y = top_y + Hold.HEIGHT
self.scr.leaveok(True)
self.matrix = Matrix(self, left_x, top_y) self.matrix = Matrix(self, left_x, top_y)
self.hold = Hold(side_width, left_x, top_y) self.hold = Hold(side_width, left_x, top_y)
self.next = Next(side_width, right_x, top_y) self.next = Next(side_width, right_x, top_y)
@ -549,8 +551,6 @@ class Game:
self.controls = Controls(side_width, side_height, right_x, bottom_y) self.controls = Controls(side_width, side_height, right_x, bottom_y)
self.playing = True self.playing = True
self.paused = False self.paused = False
self.scr.nodelay(True)
self.scr.getch()
self.hold.refresh() self.hold.refresh()
self.matrix.refresh() self.matrix.refresh()
self.next.refresh() self.next.refresh()
@ -644,7 +644,6 @@ class Game:
self.new_piece(self.matrix.piece) self.new_piece(self.matrix.piece)
def over(self): def over(self):
self.playing = False
self.matrix.refresh() self.matrix.refresh()
self.matrix.window.addstr(10, 9, "GAME", curses.A_BOLD) self.matrix.window.addstr(10, 9, "GAME", curses.A_BOLD)
self.matrix.window.addstr(11, 9, "OVER", curses.A_BOLD) self.matrix.window.addstr(11, 9, "OVER", curses.A_BOLD)
@ -652,6 +651,7 @@ class Game:
self.scr.nodelay(False) self.scr.nodelay(False)
while self.scr.getkey() != CONTROLS["QUIT"]: while self.scr.getkey() != CONTROLS["QUIT"]:
pass pass
quit()
def quit(self): def quit(self):
self.playing = False self.playing = False