Commit 7caf7af2 by BellCodeEditor

save project

parent 6c840fe7
Showing with 7 additions and 5 deletions
...@@ -48,8 +48,10 @@ cube_list=random.choice(shape_list) ...@@ -48,8 +48,10 @@ cube_list=random.choice(shape_list)
cube_index=random.randint(0,len(cube_list)-1) cube_index=random.randint(0,len(cube_list)-1)
color=random.choice(cube_colors) color=random.choice(cube_colors)
current_pos = [] current_pos = []
def check(center): def check(current_pos,o):
if center[1]<0 or center[1]>14: print(current_pos)
for i in current_pos:
if (i[1]<=1 and o==1)or(i[1]>=15 and o==2):
return True return True
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
...@@ -59,12 +61,12 @@ while True: ...@@ -59,12 +61,12 @@ while True:
if event.key == locals.K_RIGHT: # 向右 if event.key == locals.K_RIGHT: # 向右
if center[1] <15: if center[1] <15:
center[1] += 1 center[1] += 1
if check(center): if check(current_pos,2):
center[1] -= 1 center[1] -= 1
elif event.key == locals.K_LEFT: # 向左 elif event.key == locals.K_LEFT: # 向左
if center[1] > 1: if center[1]>0:
center[1] -= 1 center[1] -= 1
if check(center): if check(current_pos,1):
center[1] += 1 center[1] += 1
elif event.key == locals.K_DOWN: # 向下 elif event.key == locals.K_DOWN: # 向下
if center[0] < 25: if center[0] < 25:
......
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