Commit f84c9690 by BellCodeEditor

save project

parent fef9524f
Showing with 20 additions and 4 deletions
...@@ -6,7 +6,7 @@ score = 0 ...@@ -6,7 +6,7 @@ score = 0
grid_size = 20 # 格子大小 grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量 grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量 grid_num_height = 25 # 纵向格子数量
FPS = 3 FPS = 30
count=0 count=0
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
...@@ -14,8 +14,10 @@ pygame.display.set_caption("俄罗斯方块") ...@@ -14,8 +14,10 @@ pygame.display.set_caption("俄罗斯方块")
clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) 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)
f1 = pygame.font.Font('STKAITI.TTF', 30) # 字体
go=False
st=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)],
...@@ -60,6 +62,8 @@ def check(center): ...@@ -60,6 +62,8 @@ def check(center):
for i in range(25): for i in range(25):
sp.append([0]*15) sp.append([0]*15)
while True: while True:
if sat==False: if sat==False:
sat=True sat=True
color=random.choice(cube_colors) color=random.choice(cube_colors)
...@@ -68,9 +72,17 @@ while True: ...@@ -68,9 +72,17 @@ while True:
index=random.randint(0,len(shape)-1) index=random.randint(0,len(shape)-1)
current_shape =shape[index] current_shape =shape[index]
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 go ==True:
go==False
sp=[]
score=0
for i in range(25):
sp.append([0]*15)
if event.key == locals.K_LEFT: if event.key == locals.K_LEFT:
center[1]=center[1]-1 # 向右 center[1]=center[1]-1 # 向右
if check(center)==False: if check(center)==False:
...@@ -139,8 +151,12 @@ while True: ...@@ -139,8 +151,12 @@ while True:
else: else:
score+=1 score+=1
sp=sq sp=sq
if sp[1][7]!=0:
go=True
t1 = f1.render("你个呲球,点任意键重玩", True, (255, 0, 0))
screen.blit(t1, (150,100))
# 得分
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))
# 刷新画面 # 刷新画面
......
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