Commit ed5fb987 by BellCodeEditor

save project

parent 373b7d37
Showing with 13 additions and 7 deletions
...@@ -7,7 +7,7 @@ grid_size = 20 # 格子大小 ...@@ -7,7 +7,7 @@ grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量 grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量 grid_num_height = 25 # 纵向格子数量
FPS = 30 FPS = 30
count = 0
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块") pygame.display.set_caption("俄罗斯方块")
...@@ -65,21 +65,27 @@ while True: ...@@ -65,21 +65,27 @@ while True:
if center[1] < 15: if center[1] < 15:
center[1] += 1 center[1] += 1
elif event.key == locals.K_LEFT: # 向左 elif event.key == locals.K_LEFT: # 向左
certer[1] = certer[1] - 1 if center[1] > 1:
if cheak(center) == False: center[1] -= 1
center[1] = center[1] + 1
elif event.key == locals.K_DOWN: # 向下 elif event.key == locals.K_DOWN: # 向下
if center[0] < 25: center[0] = certer[0] + 1
center[0] += 1 if check(certer) == False:
center[0] = certer[0] - 1
elif event.key == locals.K_UP: elif event.key == locals.K_UP:
old_index = index old_index = index
index += 1 index += 1
if index >= len(shape): if index >= len(shape):
index = 0 index = 0
current_shape = shape[index] current_shape = shape[index]
if cheak(center) == False: if check(certer) == False:
index = old_index index = old_index
current_shape = shape[index] current_shape = shape[index]
count += 1
if count % FPS == 0:
certer[0] = certer[0] + 1
if check(certer) == False:
certer[0] = certer[0] - 1
# 将背景图画上去 # 将背景图画上去
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