Commit 85b0daf5 by BellCodeEditor

save project

parent 0951c0bd
Showing with 13 additions and 13 deletions
...@@ -53,9 +53,6 @@ def check(center): ...@@ -53,9 +53,6 @@ def check(center):
return False return False
while True: while True:
shape = random.choice(shape_list)
way = random.randint(0,len(shape)-1)
color = random.choice(cube_colors)
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
...@@ -68,10 +65,6 @@ while True: ...@@ -68,10 +65,6 @@ while True:
center[1] -= 1 center[1] -= 1
if check(center) == False: if check(center) == False:
center[1]+=1 center[1]+=1
elif event.key == locals.K_DOWN: # 向下
center[0] += 1
if check(center) == False:
center[0]-=1
elif event.key == locals.K_UP: elif event.key == locals.K_UP:
old_way=way old_way=way
way +=1 way +=1
...@@ -81,6 +74,18 @@ while True: ...@@ -81,6 +74,18 @@ while True:
if check(center) == False: if check(center) == False:
way=old_way way=old_way
current_shape=shape[way] current_shape=shape[way]
if states==False:
states=True
center=[2,8]
shape = random.choice(shape_list)# 形状
way = random.randint(0,len(shape)-1)# 方向
color = random.choice(cube_colors)# 颜色
count += 1 # 向下
if count%FPS==0:# 减速公式
center[0] += 1
if check(center) == False:
center[0]-=1
states=False
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 计算出所有小方块的行、列位置 # 计算出所有小方块的行、列位置
...@@ -92,15 +97,10 @@ while True: ...@@ -92,15 +97,10 @@ while True:
for cube in current_pos: for cube in current_pos:
pygame.draw.rect(screen,color,(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0) pygame.draw.rect(screen,color,(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0)
pygame.draw.rect(screen, (255, 255, 255), pygame.draw.rect(screen, (255, 255, 255),
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1) (cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1)
# 得分 # 得分
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))
count+=1
if count%FPS==0:
center[0]+=1
if check(center)==False:
center[0]-=1
# 刷新画面 # 刷新画面
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