Commit deffe720 by BellCodeEditor

save project

parent 609d0c7c
Showing with 16 additions and 1 deletions
...@@ -40,7 +40,7 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)], ...@@ -40,7 +40,7 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(-1, 0), (0, 0), (1, 0), (-1, -1)], [(-1, 0), (0, 0), (1, 0), (-1, -1)],
[(0, -1), (0, 0), (0, 1), (-1, 1)]] [(0, -1), (0, 0), (0, 1), (-1, 1)]]
shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块 shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
gameover=False
# 一些RGB颜色 # 一些RGB颜色
cube_colors = [ cube_colors = [
(204, 153, 153), (102, 102, 153),(153, 0, 102), (204, 153, 153), (102, 102, 153),(153, 0, 102),
...@@ -61,11 +61,14 @@ def check(center): ...@@ -61,11 +61,14 @@ def check(center):
num_list = [] num_list = []
for i in range(25): for i in range(25):
num_list.append([0] * 15) num_list.append([0] * 15)
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
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:
...@@ -91,6 +94,7 @@ while True: ...@@ -91,6 +94,7 @@ while True:
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列
...@@ -139,7 +143,16 @@ while True: ...@@ -139,7 +143,16 @@ while True:
new_index-=1 new_index-=1
else: else:
core+=1 core+=1
if num_list[1][7]!=0:
gameover=True
if gameover==True:
text=font.render("游戏失败,任意键开始",True,(0,0,0))
screen.blit(text,(20,50))
score=0
num_list = []
for i in range(25):
num_list.append([0] * 15)
...@@ -151,3 +164,4 @@ while True: ...@@ -151,3 +164,4 @@ while True:
# 刷新画面 # 刷新画面
pygame.display.update() 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