Commit 4640681b by BellCodeEditor

save project

parent 1c7e7e19
Showing with 12 additions and 0 deletions
...@@ -40,6 +40,12 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)], ...@@ -40,6 +40,12 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(-1, 0), (0, 0), (1, 0), (-1, -1)], [(-1, 0), (0, 0), (1, 0), (-1, -1)],
[(0, -1), (0, 0), (0, 1), (-1, 1)]] [(0, -1), (0, 0), (0, 1), (-1, 1)]]
shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块 shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
num_list=[]
for i in range(25):
num_list.append([0]*15)
print(num_list)
# 一些RGB颜色 # 一些RGB颜色
cube_colors = [ cube_colors = [
...@@ -48,7 +54,10 @@ cube_colors = [ ...@@ -48,7 +54,10 @@ cube_colors = [
(153, 0, 51), (204, 255, 102), (255, 153, 0)] (153, 0, 51), (204, 255, 102), (255, 153, 0)]
def check(center): def check(center):
for cube in current_shape: for cube in current_shape:
if num_list[cube[0]-1][cube[1]-1]!=0:
return False
cube = (cube[0] + center[0], cube[1] + center[1]) cube = (cube[0] + center[0], cube[1] + center[1])
# 当前的小方块超出网格的行、列,就返回False # 当前的小方块超出网格的行、列,就返回False
if cube[0] < 1 or cube[1] < 1 or cube[0] > grid_num_height \ if cube[0] < 1 or cube[1] < 1 or cube[0] > grid_num_height \
...@@ -84,6 +93,9 @@ while True: ...@@ -84,6 +93,9 @@ while True:
if check(center) == False: if check(center) == False:
index = old_index index = old_index
current_shape = shape[index] current_shape = shape[index]
current_pos=[]
for cube in current_pos:
num_list[cube[0]-1][cube[1]-1]=color
if states == False: if states == False:
states = True states = True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment