Commit 865a8fe7 by BellCodeEditor

save project

parent 10c738ca
Showing with 22 additions and 0 deletions
...@@ -49,12 +49,14 @@ current_shape1 = random.choice(shape_list) ...@@ -49,12 +49,14 @@ current_shape1 = random.choice(shape_list)
index = random.randint(0,len(current_shape1)-1) index = random.randint(0,len(current_shape1)-1)
current_shape = current_shape1[index] current_shape = current_shape1[index]
color = random.choice(cube_colors) color = random.choice(cube_colors)
zt1 = 0
def cheaf(center): def cheaf(center):
for cube in current_shape: for cube in current_shape:
cube = (cube[0] + center[0], cube[1] + center[1]) 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: if cube[0] < 1 or cube[1] < 1 or cube[0] > grid_num_height or cube[1] >grid_num_width:
return False return False
while True: while True:
old_zuobiao = []
fps2 += 1 fps2 += 1
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -91,6 +93,12 @@ while True: ...@@ -91,6 +93,12 @@ while True:
zt = True zt = True
if zt: if zt:
zt = False zt = False
for cube in current_shape:
pos = (cube[0] + center[0], cube[1] + center[1])
current_pos.append(pos)
for cube in current_pos:
old_zuobiao.append([cube[0],cube[1],center,current_shape,color])
zt1 = 1
center = [2, 8] center = [2, 8]
current_shape1 = random.choice(shape_list) current_shape1 = random.choice(shape_list)
index = random.randint(0,len(current_shape1)-1) index = random.randint(0,len(current_shape1)-1)
...@@ -110,6 +118,20 @@ while True: ...@@ -110,6 +118,20 @@ while True:
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0) (cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0)
pygame.draw.rect(screen, (255, 255, 255), pygame.draw.rect(screen, (255, 255, 255),
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1) (cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1)
newcurrent_pos = []
if zt1 == 1:
for cube in old_zuobiao[3]:
print(cube)
print(old_zuobiao)
pos = (cube[0] + old_zuobiao[2][0], cube[1] + old_zuobiao[2][1])
print(pos)
newcurrent_pos.append(pos)
# 取出所有小方块的行、列位置,计算坐标,绘制俄罗斯方块
for cube in newcurrent_pos:
pygame.draw.rect(screen, old_zuobiao[4],
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 0)
pygame.draw.rect(screen, (255, 255, 255),
(cube[1] * 20-20, cube[0] * 20-20, 20, 20), 1)
# 得分 # 得分
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