Commit 419d5b8d by BellCodeEditor

auto save

parent 99d4e810
Showing with 20 additions and 8 deletions
......@@ -51,10 +51,19 @@ cube_colors = [
(153, 0, 51), (204, 255, 102), (255, 153, 0)]
center = [2, 8] # 第2行第8列
current_shape = random.choice(shape_list)
index = random.randint(0,len(current_shape)-1)
current_shape = current_shape[index]
color = random.choice(cube_colors)
shape = random.choice(shape_list)
index = random.randint(0,len(shape)-1)
current_shape = shape[index]
r = random.randint(0,255)
g = random.randint(0,255)
b = random.randint(0,255)
color = (r,g,b)
def check(center):
for cube in current_shape:
cube = (cube[0]+center[0],cube[1]+center[1])
if cube[0]<1 or cube[0]>25 or cube[1]<1 or cube[1]>15:
return False
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -62,16 +71,19 @@ while True:
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT: # 向右
center[1] += 1
if check(center)==False:
center[1]-=1
if check(center) == False:
center[1] -= 1
elif event.key == locals.K_LEFT: # 向左
center[1] -= 1
if check(center)==False:
center[1]+=1
elif event.key == locals.K_DOWN: # 向下
center[0] += 1
if check(center)==False:
center[0]-=1
if check(center) == False:
center[0] -= 1
elif event.key == locals.K_UP:
# 将背景图画上去
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