Commit 9ae82456 by BellCodeEditor

save project

parent 6ab3f11c
Showing with 18 additions and 3 deletions
...@@ -9,6 +9,8 @@ grid_num_width = 15 # 横向格子数量 ...@@ -9,6 +9,8 @@ grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量 grid_num_height = 25 # 纵向格子数量
FPS = 30 FPS = 30
index = 0 index = 0
count = 0
skakes = False
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
...@@ -45,7 +47,6 @@ cube_colors = [ ...@@ -45,7 +47,6 @@ cube_colors = [
(204, 153, 153), (102, 102, 153),(153, 0, 102), (204, 153, 153), (102, 102, 153),(153, 0, 102),
(255, 204, 0), (204, 0, 51),(255, 0, 51), (0, 102, 153), (255, 204, 0), (204, 0, 51),(255, 0, 51), (0, 102, 153),
(153, 0, 51), (204, 255, 102), (255, 153, 0)] (153, 0, 51), (204, 255, 102), (255, 153, 0)]
center = [2, 8] # 第2行第8列 center = [2, 8] # 第2行第8列
random_shape = shape_list[random.randint(0,len(shape_list)-1)] random_shape = shape_list[random.randint(0,len(shape_list)-1)]
shape_index = random.randint(0,len(random_shape)-1) shape_index = random.randint(0,len(random_shape)-1)
...@@ -55,7 +56,7 @@ color = cube_colors[random.randint(0,len(cube_colors)-1)] ...@@ -55,7 +56,7 @@ color = cube_colors[random.randint(0,len(cube_colors)-1)]
def check(center): def check(center):
for cube in current_shape: for cube in current_shape:
cube = (cube[0] + center[0],cube[1] + center[1]) cube = (cube[0] + center[0],cube[1] + center[1])
if cube[0] < 1 or cube[1] < 1 or cube[1] > 15 or cube[0] > 25: if cube[0] < 1 or cube[1] < 1 or cube[1] > grid_num_width or cube[0] > grid_num_height:
return False return False
while True: while True:
...@@ -86,7 +87,21 @@ while True: ...@@ -86,7 +87,21 @@ while True:
if check(center) == False: if check(center) == False:
shape_index = old_index shape_index = old_index
current_shape = random_shape[shape_index] current_shape = random_shape[shape_index]
if skakes == False:
skakes = True
center = [2, 8] # 第2行第8列
random_shape = shape_list[random.randint(0,len(shape_list)-1)]
shape_index = random.randint(0,len(random_shape)-1)
current_shape = random_shape[shape_index]
color = cube_colors[random.randint(0,len(cube_colors)-1)]
count += 1
if count % FPS == 0:
center[0] += 1
if check(center) == False:
center[0] -= 1
skakes = False
print(skakes)
print(count)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 计算出所有小方块的行、列位置 # 计算出所有小方块的行、列位置
......
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