Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson10_diy2

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit c0ca7fe9 authored 2 years ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent b6350596
Show whitespace changes
Inline Side-by-side
Showing with 25 additions and 0 deletions
  • my_Tetris.py
my_Tetris.py
View file @ c0ca7fe9
...@@ -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)
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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