Commit 138985d3 by BellCodeEditor

save project

parent 773a1302
Showing with 5 additions and 1 deletions
...@@ -59,6 +59,8 @@ while True: ...@@ -59,6 +59,8 @@ while True:
apple_y = random.randint(0,21)*30 apple_y = random.randint(0,21)*30
else: else:
position.pop(0) position.pop(0)
if x<0 or x>630 or y<0 or y>450:
exit()
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
...@@ -66,10 +68,12 @@ while True: ...@@ -66,10 +68,12 @@ while True:
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
for i in range(len(position)-1): for i in range(len(position)-1):
screen.blit(body, position[i]) screen.blit(body, position[i])
if position[i] == (x,y):
exit()
# 将果实画上去 # 将果实画上去
text = 'Score:'+str(score) text = 'Score:'+str(score)
info = myfont.render(text,True,(20,20,20)) info = myfont.render(text,True,(0,255,0))
screen.blit(info, (540,10)) screen.blit(info, (540,10))
screen.blit(food, (apple_x, apple_y)) screen.blit(food, (apple_x, apple_y))
# 刷新画面 # 刷新画面
......
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