Commit 1e84563a by BellCodeEditor

save project

parent c6d97ff4
Showing with 6 additions and 0 deletions
...@@ -10,6 +10,7 @@ apple=pygame.image.load('apple.png') ...@@ -10,6 +10,7 @@ apple=pygame.image.load('apple.png')
left=pygame.image.load('left.png') left=pygame.image.load('left.png')
down=pygame.image.load('down.png') down=pygame.image.load('down.png')
up=pygame.image.load('up.png') up=pygame.image.load('up.png')
my_font=pygame.font.Font('neuropol.ttf',20)
# 创建一个窗口 # 创建一个窗口
screen=pygame.display.set_mode((660,480)) screen=pygame.display.set_mode((660,480))
x,y=150,120 x,y=150,120
...@@ -18,6 +19,7 @@ apple_y=60 ...@@ -18,6 +19,7 @@ apple_y=60
s=[(60,120),(90,120),(120,120),(x,y)] s=[(60,120),(90,120),(120,120),(x,y)]
setheading='right' setheading='right'
tou=right tou=right
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,6 +51,7 @@ while True: ...@@ -49,6 +51,7 @@ while True:
z=random.randint(1,16) z=random.randint(1,16)
apple_x=h*30-30 apple_x=h*30-30
apple_y=z*30-30 apple_y=z*30-30
score=score+1
else: else:
s.pop(0) s.pop(0)
screen.blit(bg,(0,0)) screen.blit(bg,(0,0))
...@@ -56,6 +59,9 @@ while True: ...@@ -56,6 +59,9 @@ while True:
screen.blit(apple,(apple_x,apple_y)) screen.blit(apple,(apple_x,apple_y))
for i in range(len(s)-1): for i in range(len(s)-1):
screen.blit(body,s[i]) screen.blit(body,s[i])
info="Score"+str(score)
text=my_font.render(info,True,(0,160,210))
screen.blit(text,(540,10))
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(6) FPSCLOCK.tick(6)
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