Commit b7346835 by BellCodeEditor

save project

parent e2aa36a4
Showing with 19 additions and 1 deletions
...@@ -18,7 +18,25 @@ while True: ...@@ -18,7 +18,25 @@ while True:
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
x+=30 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'
if setheading =='night':
x += 30
elif setheading =='right':
x -= 30
elif setheading =='left':
x -= 30
elif setheading =='up':
x += 30
elif setheading =='down':
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