Commit 88c53386 by BellCodeEditor

save project

parent 7f972e5e
Showing with 7 additions and 7 deletions
......@@ -19,19 +19,19 @@ food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
left = pygame.image.load('left.png')
up = pygame.image.load('up.png')
down = pygame.image.load('down,png')
down = pygame.image.load('down.png')
x,y=240,120
setheading = 'right'
snke_head = right
ed=[(180, 90),(180, 120),(210,120),(x,y)]
setheading=[(180, 90),(180, 120),(210,120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN
if event.type == locals.KEYDOWN:
if event.type == locals.K_RIGHT and setheading !="left":
setheading = 'right'
snke_head = right
......@@ -52,16 +52,16 @@ while True:
y -= 30
if setheading == "down":
y += 30
ed.append((x,y))
ed.pop(0)
setheading.append((x,y))
setheading.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, ed[-1])
screen.blit(snke_head, setheading[-1])
# 将贪吃蛇的身体画上去
for i in range(len(ed)-1):
screen.blit(body,ed[i])
screen.blit(body,setheading[i])
# screen.blit(body, (210, 120))
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
......
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