Commit c0ca7fe9 by BellCodeEditor

save project

parent b6350596
Showing with 25 additions and 0 deletions
...@@ -9,6 +9,8 @@ grid_num_height = 25 # 纵向格子数量 ...@@ -9,6 +9,8 @@ grid_num_height = 25 # 纵向格子数量
FPS = 30 FPS = 30
# 创建窗口 # 创建窗口
screen = pygame.display.set_mode((460, 500)) screen = pygame.display.set_mode((460, 500))
pygame.display.set_caption("俄罗斯方块") pygame.display.set_caption("俄罗斯方块")
clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数) clock = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
...@@ -20,6 +22,21 @@ while True: ...@@ -20,6 +22,21 @@ while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
exit() exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT:
center[1] < 15:
elif event.type == locals.KEY_LEFT:
center[0]-=1
elif event.type == locals.KEYDOWN:
if center[0]< 25:
center[0] = center[0] + 1
# 将背景图画上去 # 将背景图画上去
screen.blit(background,(0,0)) screen.blit(background,(0,0))
...@@ -31,3 +48,11 @@ while True: ...@@ -31,3 +48,11 @@ while True:
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
clock.tick(FPS) clock.tick(FPS)
pygame.darw.rect(screen,(255,0,0),
(center[1]*20-20,center[0]*20-20,
20,20),
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