Commit af255b9e by BellCodeEditor

save project

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