Commit 2f04ed5b by BellCodeEditor

save project

parent 0f8390ef
Showing with 7 additions and 0 deletions
...@@ -22,6 +22,7 @@ x, y = 240, 120 ...@@ -22,6 +22,7 @@ x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
apple_x = 360 apple_x = 360
apple_y = 300 apple_y = 300
score = 0
setheading = "right" setheading = "right"
snake_head = right snake_head = right
...@@ -66,6 +67,8 @@ while True: ...@@ -66,6 +67,8 @@ while True:
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
if x < 0 or x > 630 or y > 0 or y < 480:
exit()
# 将贪吃蛇的头画上去 # 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1]) screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
...@@ -74,6 +77,9 @@ while True: ...@@ -74,6 +77,9 @@ while True:
# 将果实画上去 # 将果实画上去
screen.blit(food, (apple_x,apple_y)) screen.blit(food, (apple_x,apple_y))
into = "Score" + str(score)
text = my_font.render(info,True,(0,0,0))
score.bilt(text,(540,10))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
FPSCLOCK.tick(3) 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