Commit 0bbc60a9 by BellCodeEditor

save project

parent a0612cc5
Showing with 14 additions and 15 deletions
......@@ -19,7 +19,7 @@ up = pygame.image.load('up.png')
OKCLOCK=pygame.time.Clock()
x,y=240,120
yuhotui=[(180,90),(180,120),(210,120),(x,y)]
position=[(180,90),(180,120),(210,120),(x,y)]
setheading = "up"
snake_haed = up
......@@ -30,22 +30,22 @@ while True:
exit()
elif event.type==locals.KEYDOWN:
if event.key==locals.K_RIGHT and setheading!="left":
if event.key==locals.K_RIGHT and setheading != "left":
setheading="right"
snake_haed=right
if event.key==locals.K_UP and setheading!="down":
if event.key==locals.K_UP and setheading != "down":
setheading="up"
snake_haed=up
if event.key==locals.K_LEFT and setheading!="right":
if event.key==locals.K_LEFT and setheading != "right":
setheading="left"
snake_haed=left
if event.key==locals.K_DOWN and setheading!="up":
if event.key==locals.K_DOWN and setheading != "up":
setheading="down"
snake_haed=down
if event.key==locals.K_SPACE:
OKCLOCK.tick(100)
else:
OKCLOCK.tick(3)
# if event.key==locals.K_SPACE:
# OKCLOCK.tick(100)
# else:
# OKCLOCK.tick(3)
if setheading == "right":
x+=30
elif setheading=="left":
......@@ -62,18 +62,16 @@ while True:
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, (x, y))
screen.blit(snake_haed, (x, y))
# 将贪吃蛇的身体画上去
# screen.blit(body, (210, 120))
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
for i in range(len(yuhotui)-1):
screen.blit(body,yuhotui[i])
for i in range(len(position)-1):
screen.blit(body,position[i])
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
x+=30
yuhotui.append((x,y))
yuhotui.pop(0)
OKCLOCK.tick(3)
\ No newline at end of file
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