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)],
[(-1, 0), (0, 0), (1, 0), (-1, -1)],
[(0, -1), (0, 0), (0, 1), (-1, 1)]]
shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
gameover=False
# 一些RGB颜色
cube_colors = [
(204, 153, 153), (102, 102, 153),(153, 0, 102),
......@@ -61,11 +61,14 @@ def check(center):
num_list = []
for i in range(25):
num_list.append([0] * 15)
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
if event.type == locals.KEYDOWN:
if gameover==True:
gameover=False
if event.key == locals.K_LEFT: # 向左
center[1] = center[1] - 1 # 左移1列
if check(center) == False:
......@@ -91,6 +94,7 @@ while True:
index = old_index
current_shape = shape[index]
# 生成新俄罗斯方块
if gameover==False:
if states == False:
states = True
center = [2, 8] # 第2行第8列
......@@ -139,7 +143,16 @@ while True:
new_index-=1
else:
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:
# 刷新画面
pygame.display.update()
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