Commit 1f245d1c by BellCodeEditor

save project

parent 47a0a8eb
Showing with 34 additions and 1 deletions
...@@ -14,19 +14,52 @@ background = pygame.image.load('bg.png') ...@@ -14,19 +14,52 @@ background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.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")
fgf="right"
tupian=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()
if event.type==locals.KEYDOWN:
if event.key == locals.K_UP:
fgf="up"
#x-=30
tupian=up
if event.key == locals.K_DOWN:
fgf="down"
#x-=30
tupian=down
if event.key == locals.K_RIGHT:
fgf="right"
#x+=30
tupian=right
if event.key == locals.K_LEFT:
fgf="left"
#x+=30
tupian=left
if fgf=="up":
y-=30
elif fgf=="down":
y+=30
elif fgf=="left":
x-=30
else:
x+=30 x+=30
pvj.append((x,y)) pvj.append((x,y))
pvj.pop(0) pvj.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(tupian,pvj[3])
for i in range(len(pvj)-1): for i in range(len(pvj)-1):
screen.blit(right,pvj[3])
screen.blit(body,pvj[i]) screen.blit(body,pvj[i])
# 将贪吃蛇画上去 # 将贪吃蛇画上去
......
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