litris update
This commit is contained in:
30
litris.py
30
litris.py
@@ -1,3 +1,5 @@
|
||||
from copy import copy
|
||||
|
||||
import cv2 as cv
|
||||
import numpy as np
|
||||
from game_base_class import GameBase
|
||||
@@ -25,6 +27,7 @@ class Litris(GameBase):
|
||||
self.fill_data_coordinates()
|
||||
|
||||
self.field = Field()
|
||||
self.field_mem = Field()
|
||||
|
||||
#self.sd_reset_board = cv.imread("control_elements/sodoku_reset_button.jpg", cv.IMREAD_COLOR)
|
||||
|
||||
@@ -32,11 +35,6 @@ class Litris(GameBase):
|
||||
|
||||
self.move_mode = 1
|
||||
|
||||
|
||||
def reset_field(self):
|
||||
self.state = [[' ' for cols in range(Field.WIDTH)]
|
||||
for rows in range(Field.HEIGHT)]
|
||||
|
||||
def fill_data_coordinates(self):
|
||||
# 610 to 1950 = 1340 - 76 / 20 = 63
|
||||
# 40 to 1380 = 1340 - 76 / 20 = 63
|
||||
@@ -69,11 +67,11 @@ class Litris(GameBase):
|
||||
|
||||
current_tetromino = Tetromino.create(current_letter)
|
||||
if self.move_mode == 2:
|
||||
current_tetromino.rotate(1)
|
||||
current_tetromino.rotate(3)
|
||||
elif self.move_mode == 3:
|
||||
current_tetromino.rotate(2)
|
||||
elif self.move_mode == 4:
|
||||
current_tetromino.rotate(3)
|
||||
current_tetromino.rotate(1)
|
||||
|
||||
|
||||
opt = Optimizer.get_optimal_drop(self.field, current_tetromino)
|
||||
@@ -87,12 +85,20 @@ class Litris(GameBase):
|
||||
self.field.drop(current_tetromino, column)
|
||||
self.move_stone(column - offset_col, rotation)
|
||||
self.drop_down()
|
||||
self.stone_id_thread.set_pick_up_status(False)
|
||||
print(self.field)
|
||||
#if self.field.get_line_count() % 6 == 0:
|
||||
# self.field.rotate_state()
|
||||
# self.update_move_mode()
|
||||
# self.field.cleared_rows = 1
|
||||
if self.field.get_line_count() >= 10:
|
||||
self.update_move_mode()
|
||||
self.field.rotate_state()
|
||||
#self.update_move_mode()
|
||||
#self.field.reset_field()
|
||||
#field_mem = copy(self.field)
|
||||
#self.field = copy(self.field_mem)
|
||||
#self.field_mem = copy(field_mem)
|
||||
|
||||
self.field.cleared_rows = 1
|
||||
|
||||
cv.waitKey(200)
|
||||
self.stone_id_thread.set_pick_up_status(False)
|
||||
|
||||
|
||||
def drop_down(self):
|
||||
|
||||
Reference in New Issue
Block a user