Commit c7228f5d by BellCodeEditor

save project

parent 4533a943
Showing with 13 additions and 2 deletions
......@@ -6,6 +6,7 @@ score = 0
grid_size = 20 # 格子大小
grid_num_width = 15 # 横向格子数量
grid_num_height = 25 # 纵向格子数量
rect = [8,1]
FPS = 30
# 创建窗口
screen = pygame.display.set_mode((460, 500))
......@@ -20,8 +21,18 @@ while True:
if event.type == locals.QUIT:
exit()
screen.blit(background,(0,0)) # 将背景图画上去
pygame.draw.rect(screen,(0,150,255),(120,20,20,20),0)
pygame.draw.rect(screen,(255,255,255),(120,20,20,20),1)
if event.type == locals.KEYDOWN:
if event.key == locals.K_LEFT:
if rect[0]>1:
rect[0]-=1
elif event.key == locals.K_RIGHT:
if rect[0]<15:
rect[0]+=1
elif event.key == locals.K_DOWN:
if rect[1]<20:
rect[1]+=1
pygame.draw.rect(screen,(0,150,255),(rect[0]*20-20,rect[1]*20-20,20,20),0)
pygame.draw.rect(screen,(255,255,255),(rect[0]*20-20,rect[1]*20-20,20,20),1)
screen.blit(text,(350,70)) # 得分
pygame.display.update() # 刷新画面
clock.tick(FPS)
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