Commit 74b863f8 by BellCodeEditor

save project

parent 96666585
Showing with 6 additions and 2 deletions
...@@ -6,7 +6,7 @@ fps=pygame.time.Clock() ...@@ -6,7 +6,7 @@ fps=pygame.time.Clock()
x,y=240,120 x,y=240,120
p=[(180,90),(180,120),(210,120),(x,y)] p=[(180,90),(180,120),(210,120),(x,y)]
apple_x=360 apple_x=360
apple_y= apple_y=300
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
...@@ -43,12 +43,15 @@ while True: ...@@ -43,12 +43,15 @@ while True:
y-=30 y-=30
elif setheading =="down": elif setheading =="down":
y+=30 y+=30
if x==apple_x and y==apple_y:
apple_x=random.randint(0,660)
apple_y=random.randint(0,480)
p.append((x,y)) p.append((x,y))
p.pop(0) p.pop(0)
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
screen.blit(snake_head, (x,y)) screen.blit(snake_head, (x,y))
for i in range(len(p)-1): for i in range(len(p)-1):
screen.blit(body,p[i]) screen.blit(body,p[i])
screen.blit(food, (360, 300)) screen.blit(food, (apple_x, apple_y))
pygame.display.update() pygame.display.update()
fps.tick(3) fps.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