Commit b22889b2 by BellCodeEditor

save project

parent 861cf2b3
Showing with 8 additions and 3 deletions
...@@ -4,6 +4,7 @@ from pygame import locals ...@@ -4,6 +4,7 @@ from pygame import locals
pygame.init() pygame.init()
fps=pygame.time.Clock() fps=pygame.time.Clock()
x,y=240,120 x,y=240,120
my_font=pygame.font.Font("neuropol.ttf",18)
apple_x=360 apple_x=360
apple_y=300 apple_y=300
p=[(180,90),(180,120),(210,120),(x,y)] p=[(180,90),(180,120),(210,120),(x,y)]
...@@ -17,7 +18,7 @@ down = pygame.image.load('down.png') ...@@ -17,7 +18,7 @@ down = pygame.image.load('down.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
setheading ="right" setheading ="right"
snake_head =right snake_head =right
text=pygame. score=0
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:
...@@ -49,14 +50,17 @@ while True: ...@@ -49,14 +50,17 @@ while True:
num2=random.randint(1,16) num2=random.randint(1,16)
apple_x=30*num1-30 apple_x=30*num1-30
apple_y=30*num2-30 apple_y=30*num2-30
score=score+10
else: else:
p.pop(0) p.pop(0)
if x<0 or
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, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
info="Store" info="Score"+str(score)
test=my_font.render(info,True,(66,66,66))
screen.blit(test,(540,10))
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