Commit d299463e by BellCodeEditor

save project

parent 25160652
Showing with 17 additions and 2 deletions
...@@ -10,6 +10,7 @@ grid_num_height = 25 # 纵向格子数量 ...@@ -10,6 +10,7 @@ grid_num_height = 25 # 纵向格子数量
FPS = 30 # 帧率 FPS = 30 # 帧率
count = 0 count = 0
states = False states = False
gameover = False
num_list = [] num_list = []
for i in range(25): for i in range(25):
num_list.append([0]*15) num_list.append([0]*15)
...@@ -64,6 +65,8 @@ while True: ...@@ -64,6 +65,8 @@ 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
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:
...@@ -90,14 +93,17 @@ while True: ...@@ -90,14 +93,17 @@ while True:
if check(center) == False: if check(center) == False:
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列
shape = random.choice(shape_list) shape = random.choice(shape_list)
index = random.randint(0, len(shape)-1) # 随机形状索引 index = random.randint(0, len(shape)-1) # 随机形状索引
current_shape = shape[index] current_shape = shape[index]
color = random.choice(cube_colors) # 随机选取一种颜色 color = random.choice(cube_colors)# 随机选取一种颜色
if check(center) == False:
gameover = True
continue
count += 1 count += 1
if count % FPS == 0: # 降落速度的算式 if count % FPS == 0: # 降落速度的算式
center[0] = center[0] + 1 center[0] = center[0] + 1
...@@ -141,6 +147,15 @@ while True: ...@@ -141,6 +147,15 @@ while True:
else: else:
score += 1 score += 1
num_list = new_list num_list = new_list
if gameover == True:
num_list = []
for i in range(25):
num_list.append([0]*15)
score = 0
font_2 = pygame.font.Font('STKAITI.TTF', 30)
text_surface2 = font_2.render('勍蓭陾翳姦爞丗',True,(0,0,0))
screen.blit(text_surface2,(50,250))
# 得分 # 得分
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))
......
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