added async stone detection thread
This commit is contained in:
11
field.py
11
field.py
@@ -22,9 +22,18 @@ class Field():
|
||||
'{:2d} |'.format(i) + ' '.join(row) + '|'
|
||||
for i, row in enumerate(self.state)]) + '\n' + BAR
|
||||
|
||||
def rotate_90_degree_clckwise(matrix):
|
||||
new_matrix = []
|
||||
for i in range(len(matrix[0])):
|
||||
li = list(map(lambda x: x[i], matrix))
|
||||
li.reverse()
|
||||
new_matrix.append(li)
|
||||
|
||||
return new_matrix
|
||||
|
||||
def rotate_state(self):
|
||||
self.state = list(zip(*self.state[::-1]))
|
||||
self.state = self.rotate_90_degree_clckwise(self.state)
|
||||
print(self.state)
|
||||
|
||||
def get_line_count(self):
|
||||
return self.cleared_rows
|
||||
|
||||
12
litris.py
12
litris.py
@@ -96,7 +96,7 @@ class Litris(GameBase):
|
||||
print("offset column:", offset_col)
|
||||
self.field.drop(current_tetromino, column)
|
||||
self.move_stone(column - offset_col, rotation)
|
||||
for i in range(1,8,1):
|
||||
for i in range(1, 10, 1):
|
||||
self.keyboard.press(Key.down)
|
||||
self.keyboard.release(Key.down)
|
||||
print("direction pressed: drop down")
|
||||
@@ -253,23 +253,23 @@ class Litris(GameBase):
|
||||
else:
|
||||
return None
|
||||
|
||||
def move_stone(self, col_movement, rotation, move_mode):
|
||||
def move_stone(self, col_movement, rotation):
|
||||
if col_movement is None:
|
||||
return
|
||||
|
||||
if move_mode == 1:
|
||||
if self.move_mode == 1:
|
||||
down = Key.down
|
||||
left = Key.left
|
||||
right = Key.right
|
||||
elif move_mode == 2:
|
||||
elif self.move_mode == 2:
|
||||
down = Key.left
|
||||
left = Key.up
|
||||
right = Key.down
|
||||
elif move_mode == 3:
|
||||
elif self.move_mode == 3:
|
||||
down = Key.up
|
||||
left = Key.right
|
||||
right = Key.left
|
||||
elif move_mode == 4:
|
||||
elif self.move_mode == 4:
|
||||
down = Key.right
|
||||
left = Key.down
|
||||
right = Key.up
|
||||
|
||||
Reference in New Issue
Block a user