Skip to content

Commit

Permalink
refactory
Browse files Browse the repository at this point in the history
  • Loading branch information
vertexi committed Feb 15, 2022
1 parent 78dfefd commit 99b1524
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def __init__(self, display):
self.game_map = None
self.tetromino = None

self.update_map = self.iter_tetromino_area(self.update_map_action)
self.update_map_data = self.iter_tetromino_area(self.update_map_action)
self.collide_detect = \
self.iter_tetromino_area(self.collide_detect_action)

Expand Down Expand Up @@ -52,15 +52,17 @@ def collide_detect_action(self, tetromino_array, j, i, tetromino_y, tetromino_x)
tetromino_array[tetromino_y][tetromino_x]) > 1:
return True

def update_map(self):
self.update_map_data()
graphic.diff_draw(self.game_map)

def move_down(self):
self.tetromino.pos_y_pre = self.tetromino.pos_y
self.tetromino.pos_y += 1
if self.collide_detect():
self.tetromino.pos_y -= 1
self.update_map()
self.add_tetromino()
graphic.draw_tetromino(self.tetromino, False)
graphic.diff_draw(self.game_map)
graphic.draw_tetromino(self.tetromino)

def move_right(self):
Expand All @@ -79,6 +81,7 @@ def add_tetromino(self):
self.tetromino = Tetromino(self.cols)
if self.collide_detect():
self.game_over = True
graphic.draw_tetromino(self.tetromino, clear_pre=False)

def init_map(self):
self.game_map = \
Expand Down

0 comments on commit 99b1524

Please sign in to comment.