Commit 07d4d42d by BellCodeEditor

save project

parent febd9cb5
Showing with 10 additions and 3 deletions
......@@ -6,8 +6,6 @@ down = pygame.image.load('down.png')
x=240
y=120
position = [(180,90),(180,120),(210,120),(x,y)]
setheading="right"
snake_head=right
# 初始化pygame,为使用硬件做准备
pygame.init()
......@@ -19,6 +17,8 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
setheading="right"
snake_head=right
while True:
for event in pygame.event.get():
......@@ -38,7 +38,14 @@ while True:
if event.key == locals.K_down and setheading != "up":
setheading="down"
snake_head=down
x += 30
if setheading=="right":
x+=30
elif setheading=="left":
x-=30
elif setheading=="up":
y+=30
else:
y+=30
position.append((x,y))
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