Commit b932f7fc by BellCodeEditor

save project

parent 4728de1b
Showing with 11 additions and 3 deletions
......@@ -37,7 +37,7 @@ L = [[(-1, 0), (0, 0), (1, 0), (1, 1)],
[(-1, 0), (0, 0), (1, 0), (-1, -1)],
[(0, -1), (0, 0), (0, 1), (-1, 1)]]
shape_list = [I, J, L, O, S, T, Z] # 7种类型俄罗斯方块
count=0
# 一些RGB颜色
cube_colors = [
(204, 153, 153), (102, 102, 153),(153, 0, 102),
......@@ -50,7 +50,7 @@ color=random.choice(cube_colors)
current_pos = []
def check(current_pos,o):
for i in current_pos:
if (i[1]<=1 and o==1)or(i[1]>=15 and o==2):
if (i[1]<=1 and o==1)or(i[1]>=15 and o==2)or(i[0]>=25 and o==3):
return True
while True:
for event in pygame.event.get():
......@@ -70,6 +70,8 @@ while True:
elif event.key == locals.K_DOWN: # 向下
if center[0] < 25:
center[0] += 1
if check(current_pos,3):
center[0] -= 1
elif event.key==locals.K_UP:
cube_index+=1
cube_index%=len(cube_list)
......@@ -80,7 +82,13 @@ while True:
else:
if check(current_pos,1):
center[1] += 1
# 将背景图画上去
count+=1
if count%FPS==1:
if center[0] < 25:
center[0] += 1
if check(current_pos,3):
center[0] -= 1
# 将背景图画上
screen.blit(background, (0, 0))
# 计算出所有小方块的行、列位置
current_pos = []
......
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