Commit c22b747d by BellCodeEditor

save project

parent 5afc0174
Showing with 12 additions and 3 deletions
......@@ -16,7 +16,9 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入素材
background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体
num_list = []
for i in range(25):
num_list.append([0]*15)
# 俄罗斯方块所有形状
O = [[(0, 0), (0, 1), (1, 0), (1, 1)]]
I = [[(0, -1), (0, 0), (0, 1), (0, 2)],
......@@ -51,7 +53,8 @@ def check(center):
cube=(cube[0]+center[0],cube[1]+center[1])
if cube[0]<1 or cube[1]<1 or cube[0]>grid_num_height or cube[1]>grid_num_width:
return False
if num_list[cube[0]-1][cube[1]-1]!=0:
return False
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -65,7 +68,11 @@ while True:
center[1] -= 1
if check(center) == False:
center[1]+=1
elif event.key == locals.K_UP:
elif event.key == locals.K_DOWN:
center[0]+=1
if check(center) == False:
center[0]-=1
elif event.key == locals.K_UP:# 改变形状
old_way=way
way +=1
if way >= len(shape):
......@@ -86,6 +93,8 @@ while True:
if check(center) == False:
center[0]-=1
states=False
for cube in current_pos:
num_list[cube[0]-1][cube[1]-1]=cube_colors
# 将背景图画上去
screen.blit(background, (0, 0))
# 计算出所有小方块的行、列位置
......
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