Commit d829545a by BellCodeEditor

save project

parent f7b2e99d
Showing with 6 additions and 3 deletions
......@@ -52,12 +52,14 @@ while True:
else:
y += 30
position.append((x, y))
if x>630 or x<0 or y>450 or y<0:
exit()
if x==apple_x and y==apple_y:
num1=random.randint(0,21)
num2=random.randint(0,15)
apple_x=num1*30
apple_y=num2*30
score=score+10
else:
position.pop(0)
# 将背景图画上去
......@@ -67,11 +69,11 @@ while True:
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
# 刷新画面
info='Score'+str(score)
text=my_font.render()
text=my_font.render(info,True,(1,1,1))
screen.blit(text,(540,10))
pygame.display.update()
FPSCLOCK.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