Commit c4f8403b by BellCodeEditor

auto save

parent c720680f
Showing with 11 additions and 0 deletions
...@@ -8,6 +8,7 @@ x=240 ...@@ -8,6 +8,7 @@ x=240
y=120 y=120
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
setheading = "right"
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
...@@ -22,6 +23,16 @@ while True: ...@@ -22,6 +23,16 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and setheading != "left":
setheading = "right"
if event.key == locals.K_LEFT and setheading != "right":
setheading = "left"
if event.key == locals.K_UP and setheading != "down":
setheading = "up"
if event.key == locals.K_DOWN and setheading != "up":
setheading = "down"
# 将背景图画上去 # 将背景图画上去
x += 30 x += 30
screen.blit(background, (0, 0)) screen.blit(background, (0, 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