Commit 0951c0bd by BellCodeEditor

save project

parent db4edc69
Showing with 10 additions and 4 deletions
...@@ -7,7 +7,8 @@ grid_size = 20 # 格子大小 ...@@ -7,7 +7,8 @@ grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量 grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量 grid_num_height = 25 # 纵向格子数量
FPS = 30 FPS = 30
count = 0
states = False
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块") pygame.display.set_caption("俄罗斯方块")
...@@ -44,9 +45,6 @@ cube_colors = [ ...@@ -44,9 +45,6 @@ cube_colors = [
(153, 0, 51), (204, 255, 102), (255, 153, 0)] (153, 0, 51), (204, 255, 102), (255, 153, 0)]
center = [2, 8] # 第2行第8列 center = [2, 8] # 第2行第8列
current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)] current_shape = [(0, -1), (0, 0), (0, 1), (-1, 0)]
shape = random.choice(shape_list)
way = random.randint(0,len(shape)-1)
color = random.choice(cube_colors)
def check(center): def check(center):
for cube in current_shape: for cube in current_shape:
...@@ -55,6 +53,9 @@ def check(center): ...@@ -55,6 +53,9 @@ 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()
...@@ -95,6 +96,11 @@ while True: ...@@ -95,6 +96,11 @@ while True:
# 得分 # 得分
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