Commit af255b9e by BellCodeEditor

save project

parent 82c5e67b
Showing with 20 additions and 19 deletions
......@@ -26,27 +26,28 @@ while True:
# 接收到退出事件后退出程序
exit()
if event.type==locals.KEYDOWN:
if event.key == locals.K_RIGHT and head!="left":
head="right"
snake_head=right
if event.key == locals.K_LEFT and head!="right":
head="left"
snake_head=left
if event.key == locals.K_UP and head!="down":
head="up"
snake_head=up
if event.key == locals.K_DOWN and head!="up":
head="down"
snake_head=down
# 将背景图画上去
if head=="right":
if event.key==locals.K_RIGHT and head != "left":
head = "right"
snake_head = right
if event.key==locals.K_LEFT and head != "right":
head = "left"
snake_head = left
if event.key==locals.K_UP and head != "down":
head = "up"
snake_head = up
if event.key==locals.K_DOWN and head != "up":
head = "down"
snake_head = down
if head == "right":
x+=30
elif head=="left":
x-=30
elif head=="down":
y+=30
else:
elif head == "left":
x-=30
elif head == "up":
y-=30
elif head == "down":
y+=30
place.append((x,y))
place.pop(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