Commit 21db8418 by BellCodeEditor

save project

parent 4f0b13cd
Showing with 25 additions and 2 deletions
...@@ -16,14 +16,37 @@ body = pygame.image.load('body.png') ...@@ -16,14 +16,37 @@ body = pygame.image.load('body.png')
x,y = 240,120 x,y = 240,120
position = [(180,90),(190,120),(210,120),(x,y)] position = [(180,90),(190,120),(210,120),(x,y)]
setheading = "right"
snake_head = right
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
x += 30 elif event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and setheading != "lefl":
setheading = 'lefl'
snake_head = lefl
if event.key == locals.K_RIGHT and setheading != "right":
setheading = 'right'
snake_head = right
if event.key == locals.K_RIGHT and setheading != "down":
setheading = 'down'
snake_head = down
if event.key == locals.K_RIGHT and setheading != "up":
setheading = 'up'
snake_head = up
if setheading == "right":
x += 30
elif setheading == "left":
x -= 30
elif setheading == "up":
y -= 30
else:
y += 30
position.append((x,y)) position.append((x,y))
position.pop(0) position.pop(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