Commit ed63de2a by BellCodeEditor

save project

parent 53a7eca4
Showing with 18 additions and 0 deletions
...@@ -18,6 +18,15 @@ while True: ...@@ -18,6 +18,15 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
if event.tpye==locals.KEYDOWN:
if event.key=locals.K_RIGHT and setheanding!="left":
setheanding="right"
if event.key=locals.K_RIGHT and setheanding!="right":
setheanding="left"
if event.key=locals.K_RIGHT and setheanding!="up":
setheanding="down"
if event.key=locals.K_RIGHT and setheanding!="down":
setheanding="up"
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
...@@ -36,3 +45,11 @@ while True: ...@@ -36,3 +45,11 @@ while True:
position.pop(0) position.pop(0)
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) FPSCLOCK.tick(3)
if event.key=locals.K_RIGHT and setheanding!="left":
setheanding="right"
if event.key=locals.K_RIGHT and setheanding!="right":
setheanding="left"
if event.key=locals.K_RIGHT and setheanding!="up":
setheanding="down"
if event.key=locals.K_RIGHT and setheanding!="down":
setheanding="up"
\ No newline at end of file
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