Commit 380076e5 by BellCodeEditor

save project

parent 1d32a580
Showing with 24 additions and 6 deletions
......@@ -10,7 +10,8 @@ grid_num_height = 25 # 纵向格子数量
FPS = 30 # 帧率
count = 0
states = False
current_pos = []
current_shape=[]
# 创建窗口
screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块")
......@@ -93,10 +94,11 @@ while True:
center[0] = center[0] + 1
if check(center) == False:
center[0] = center[0] - 1
states = False
for cube in current_pos:
num_list[cube[0]-1][cube[1]-1]=color
states = False
if states == False:
for cube in current_pos:
num_list[cube[0]-1][cube[1]-1]=color
states = True
center = [3, 8] # 第2行第8列
shape = random.choice(shape_list)
......@@ -104,7 +106,21 @@ while True:
current_shape = shape[index]
color = random.choice(cube_colors) # 随机选取一种颜色
new_list=[]
new_index=24
for i in range(25):
new_list.append([0]*15)
for i in range(24,-1,-1):
is_full=True
for j in num_list[i]:
if j==0:
is_full=False
if is_full==False:
new_list[new_index]=num_list[i]
new_index=new_index-1
else:
score+=1
num_list=new_list
# 计算出所有小方块的行、列位置
current_pos = []
for cube in current_shape:
......@@ -125,9 +141,10 @@ 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)
# 得分
text_surface = font.render(str(score), True, (0, 0, 0))
screen.blit(text_surface, (350,70))
# 刷新画面
pygame.display.update()
clock.tick(FPS)
clock.tick(FPS)
\ No newline at end of file
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