Commit d3415bce by BellCodeEditor

save project

parent bc1e7e19
Showing with 15 additions and 1 deletions
...@@ -58,16 +58,25 @@ def check(center): ...@@ -58,16 +58,25 @@ def check(center):
return False return False
if num_list[cube[0]-1][cube[1]-1]!=0: if num_list[cube[0]-1][cube[1]-1]!=0:
return False return False
gameover = False
font2 = pygame.font.Font('STKAITI.TTF', 15)
while True: while True:
if num_list[1][7] != 0:
gameover = True
for event in pygame.event.get(): for event in pygame.event.get():
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:
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:
center[1] = center[1] + 1 # 右移1列 center[1] = center[1] + 1
# 右移1列
elif event.key == locals.K_RIGHT: # 向右 elif event.key == locals.K_RIGHT: # 向右
center[1] = center[1] + 1 center[1] = center[1] + 1
...@@ -89,6 +98,7 @@ while True: ...@@ -89,6 +98,7 @@ while True:
index = old_index index = old_index
current_shape = shape[index] current_shape = shape[index]
if gameover == False:
if states == False: if states == False:
states = True states = True
center = [2, 8] # 第2行第8列 center = [2, 8] # 第2行第8列
...@@ -142,6 +152,10 @@ while True: ...@@ -142,6 +152,10 @@ while True:
# 得分 # 得分
text_surface = font.render(str(score), True, (0, 0, 0)) text_surface = font.render(str(score), True, (0, 0, 0))
screen.blit(text_surface, (350,70)) screen.blit(text_surface, (350,70))
else:
text = font2.render("游戏结束,请按任意键开始游戏",True ,(0,0,0))
screen.blit(text,(50,300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
clock.tick(FPS) clock.tick(FPS)
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