Commit 0fddc31a by BellCodeEditor

save project

parent 33a2f4f0
Showing with 12 additions and 3 deletions
......@@ -22,6 +22,8 @@ head='right'
fps=pygame.time.Clock()
a_x=360
a_y=300
myfont=pygame.font.Font(neuropol.ttf)
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -50,10 +52,14 @@ while True:
y-=30
tou=up
pos.append((x,y))
pos.pop(0)
if x==a_x and y==a_y:
a_x=random.randint(0,22)*30
a_y=random.randint(0,16)*30
a_x=random.randint(0,21)*30
a_y=random.randint(0,15)*30
score+=1
else:
pos.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
# 将背景图画上去
screen.blit(background,(0,0))
# 将贪吃蛇画上去
......@@ -63,6 +69,8 @@ while True:
screen.blit(body,pos[i])
# 将果实画上去
screen.blit(food,(a_x, a_y))
tdxt=myfont.render('Score:'+str(score),True,(0,0,0))
screen.blit(text,(540,10))
# 刷新画面
pygame.display.update()
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