Commit 2fddbea0 by BellCodeEditor

auto save

parent 53fb2d1e
Showing with 15 additions and 6 deletions
......@@ -54,6 +54,11 @@ cube_colors = [
#中心方块的初始坐标
center=[2,8]
def check(center):
for c in current_shape[index]:
cube=(c[0]+center[0],c[1]+center[1])
if cube[0]<1 or cube[0]>25 or cube[1]<1 or cube[1]<1 or cube[1]>15:
return False
#形状设计
current_shape=random.choice(shape_list)
index=random.randint(0,len(current_shape)-1)
......@@ -64,14 +69,18 @@ while True:
exit( )
if event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT:
if center[1]<15:
center[1]+=1
if event.key==locals.K_LEFT:
if center[1]>1:
center[1]+=1
if check(center)==False:
center[1]-=1
if event.key==locals.K_LEFT:
center[1]-=1
if check(center)==False:
center[1]+=1
if event.key==locals.K_DOWN:
if center[0]<25:
center[0]+=1
center[0]+=1
if check(center)==False:
center[0]-=1
......
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