Commit 0c4c8d88 by BellCodeEditor

auto save

parent 0687e059
Showing with 19 additions and 0 deletions
......@@ -133,6 +133,25 @@ while True:
(j * 20-20, i * 20-20, 20, 20))
pygame.draw.rect(screen, (255, 255, 255),
(j * 20-20, i * 20-20, 20, 20), 1)
# 新的地图列表
new_list = [] # 给新的空白列表命名为new_list
for i in range(25): # 使用for循环让程序重复执行25次
new_list.append([0] * 15) # 用num_list.append()方法将小列表添加到大列表里
# 新建变量row_index用于记录新网格列表改变的行数序号,并设为24,表示最后一行
row_index = 24
for i in range(24, -1, -1): # 结合for循环生成一个倒着排序的列表索引
# (确认每一行网格有没有被小方块填满)
is_full = True # 建立变量is_full并设为True默认网格状态被小方块填满
for j in range(grid_num_width): # for循环取出这一行网格的每一小格检查
if num_list[i][j] == 0: # if判断这一行网格的每一小格的值是否等于0
is_full = False # 如果等于0,说明还有格子没有填满,就将值设为False
if is_full == False: # if判断这一行有没有被填满
new_list[row_index] = num_list[i] # 通过下标将这一行数值赋值到新列表里
row_index -= 1 # 将序列号减少1
else: # 否则(这一行填满)
score += 1 # 分数变量score增加1
num_list = new_list # 网格列表的值new_list赋值给变量num_list,替换原来的数值
# 得分
text_surface = font.render(str(score), True, (0, 0, 0))
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