Commit dad30746 by BellCodeEditor

save project

parent efa0b061
Showing with 13 additions and 3 deletions
...@@ -18,7 +18,8 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) ...@@ -18,7 +18,8 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材 # 载入素材
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体 font = pygame.font.Font('STKAITI.TTF', 60) # 字体
font2 = pygame.font.Font('STKAITI.TTF', 25)
gameover=False
# 俄罗斯方块所有形状 # 俄罗斯方块所有形状
O = [[(0, 0), (0, 1), (1, 0), (1, 1)]] O = [[(0, 0), (0, 1), (1, 0), (1, 1)]]
I = [[(0, -1), (0, 0), (0, 1), (0, 2)], I = [[(0, -1), (0, 0), (0, 1), (0, 2)],
...@@ -61,6 +62,8 @@ def check(center): ...@@ -61,6 +62,8 @@ def check(center):
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if gameover==True:
gameover=False
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
...@@ -88,7 +91,7 @@ while True: ...@@ -88,7 +91,7 @@ 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列
...@@ -142,7 +145,14 @@ while True: ...@@ -142,7 +145,14 @@ while True:
row_index-=1 row_index-=1
else: else:
score+=1 score+=1
num_list=new_list num_list=new_list
if num_list[1][7]!=0:
gameover=True
score=0
text_surface = font2.render('游戏失败,请按任意键继续', True, (0, 0, 0))
screen.blit(text_surface, (150,175))
num_list=[]
for i in range(25):
num_list.append([0]*15)
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