Commit 7ceb3392 by BellCodeEditor

save project

parent ffd3c6a2
Showing with 10 additions and 4 deletions
...@@ -16,6 +16,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) ...@@ -16,6 +16,7 @@ clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
font = pygame.font.Font('STKAITI.TTF', 60) # 字体 font = pygame.font.Font('STKAITI.TTF', 60) # 字体
cen=[7,2] cen=[7,2]
curr_shape=[(0,-1),(0,0),(0,1),(0,2)]
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
...@@ -29,11 +30,16 @@ while True: ...@@ -29,11 +30,16 @@ while True:
cen[0]-=1 cen[0]-=1
elif event.key == locals.K_DOWN: elif event.key == locals.K_DOWN:
if cen[1]<25: if cen[1]<25:
cen[1]+=1 cen[1]+=1
# 将背景图画上去
curr_pos=[]
for cube in curr_shape:
pos=(cube[0]+cen[0],cube[1]+cen[1])
curr_pos.append(pos)
screen.blit(background,(0,0)) screen.blit(background,(0,0))
pygame.draw.rect(screen,(255,0,0),(cen[0]*20-20,cen[1]*20-20,20,20),0) for cube in curr_pos:
pygame.draw.rect(screen,(255,255,255),(cen[0]*20-20,cen[1]*20-20,20,20),1) pygame.draw.rect(screen,(255,0,0),(cube[0]*20-20,cube[1]*20-20,20,20),0)
pygame.draw.rect(screen,(255,255,255),(cube[0]*20-20,cube[1]*20-20,20,20),1)
# 得分 # 得分
sc = font.render(str(score),True,(255,255,255)) sc = font.render(str(score),True,(255,255,255))
screen.blit(sc,(350,70)) screen.blit(sc,(350,70))
......
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