Commit 7caf7af2 by BellCodeEditor

save project

parent 6c840fe7
Showing with 12 additions and 9 deletions
......@@ -48,9 +48,11 @@ cube_list=random.choice(shape_list)
cube_index=random.randint(0,len(cube_list)-1)
color=random.choice(cube_colors)
current_pos = []
def check(center):
if center[1]<0 or center[1]>14:
return True
def check(current_pos,o):
print(current_pos)
for i in current_pos:
if (i[1]<=1 and o==1)or(i[1]>=15 and o==2):
return True
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -59,13 +61,13 @@ while True:
if event.key == locals.K_RIGHT: # 向右
if center[1] <15:
center[1] += 1
if check(center):
center[1] -= 1
if check(current_pos,2):
center[1] -= 1
elif event.key == locals.K_LEFT: # 向左
if center[1] > 1:
if center[1]>0:
center[1] -= 1
if check(center):
center[1] += 1
if check(current_pos,1):
center[1] += 1
elif event.key == locals.K_DOWN: # 向下
if center[0] < 25:
center[0] += 1
......@@ -87,4 +89,4 @@ while True:
screen.blit(text_surface, (350,70))
# 刷新画面
pygame.display.update()
clock.tick(FPS)
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