Commit 74168ca8 by BellCodeEditor

save project

parent 53abc28d
Showing with 12 additions and 4 deletions
...@@ -66,6 +66,12 @@ while True: ...@@ -66,6 +66,12 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if gameover == True: # 向左
gameover = False
score = 0
num_list = []
for i in range(25):
num_list.append([0] * 15)
if event.key == locals.K_LEFT: # 向左 if event.key == locals.K_LEFT: # 向左
center[1] = center[1] - 1 # 左移1列 center[1] = center[1] - 1 # 左移1列
if check(center) == False: if check(center) == False:
...@@ -128,9 +134,9 @@ while True: ...@@ -128,9 +134,9 @@ while True:
pygame.draw.rect(screen, (255, 255, 255), pygame.draw.rect(screen, (255, 255, 255),
(j * 20-20, i * 20-20, 20, 20), 1) (j * 20-20, i * 20-20, 20, 20), 1)
num_list2 = [] num_list21 = []
for i in range(25): for i in range(25):
num_list2.append([0] * 15) num_list21.append([0] * 15)
row_index = 24 row_index = 24
for i in range(24, -1, -1): for i in range(24, -1, -1):
is_full = True is_full = True
...@@ -138,11 +144,13 @@ while True: ...@@ -138,11 +144,13 @@ while True:
if num_list[i][j] == 0: if num_list[i][j] == 0:
is_full == False is_full == False
if is_full == False: if is_full == False:
num_list2[row_index] = num_list[i] num_list21[row_index] = num_list[i]
row_index -= 1 row_index -= 1
else: else:
score += 1 score += 1
num_list = num_list2 num_list = num_list21
if num_list[1][7] != 0:
gameover = True
# 得分 # 得分
text_surface = font.render(str(score), True, (0, 0, 0)) text_surface = font.render(str(score), True, (0, 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