Commit 37c20838 by BellCodeEditor

save project

parent 87ddfa62
Showing with 10 additions and 0 deletions
...@@ -14,8 +14,13 @@ background = pygame.image.load('bg.png') ...@@ -14,8 +14,13 @@ 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')
s='right' s='right'
s=[(180,90),(180,120),(210,120),(x,y)] s=[(180,90),(180,120),(210,120),(x,y)]
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:
...@@ -24,12 +29,16 @@ while True: ...@@ -24,12 +29,16 @@ while True:
if event.type == locals.KEYDOWN: if event.type == locals.KEYDOWN:
if event.key == locals.K_RIGHT and s !="left": if event.key == locals.K_RIGHT and s !="left":
s='right' s='right'
sank_head=right
if event.key == locals.K_RIGHT and s !="right": if event.key == locals.K_RIGHT and s !="right":
s='left' s='left'
sank_head=left
if event.key == locals.K_RIGHT and s !="up": if event.key == locals.K_RIGHT and s !="up":
s='down' s='down'
sank_head=down
if event.key == locals.K_RIGHT and s !="down": if event.key == locals.K_RIGHT and s !="down":
s='up' s='up'
sank_head=up
if s=="right": if s=="right":
x += 30 x += 30
...@@ -53,6 +62,7 @@ sb.pop(0) ...@@ -53,6 +62,7 @@ sb.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(snake_head,s[-1])
screen.blit(right, (x, y)) screen.blit(right, (x, y))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
screen.blit(body, (210, 120)) screen.blit(body, (210, 120))
......
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