Commit 6a4852d4 by BellCodeEditor

save project

parent 49b2643e
Showing with 7 additions and 3 deletions
...@@ -19,10 +19,10 @@ down = pygame.image.load('down.png') # 头 朝下 ...@@ -19,10 +19,10 @@ down = pygame.image.load('down.png') # 头 朝下
ax,ay=360,300 ax,ay=360,300
x, y = 240, 120 x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)] position = [(180, 90), (180, 120), (210, 120), (x, y)]
c=pygame.font.Font("neuropol.ttf",18)
setheading = "right" setheading = "right"
snake_head = right snake_head = right
d=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:
...@@ -57,6 +57,7 @@ while True: ...@@ -57,6 +57,7 @@ while True:
b=random.randint(1,16) b=random.randint(1,16)
ax=30*a-30 ax=30*a-30
ay=30*b-30 ay=30*b-30
d+=10
else: else:
position.pop(0) position.pop(0)
# 将背景图画上去 # 将背景图画上去
...@@ -66,9 +67,11 @@ while True: ...@@ -66,9 +67,11 @@ 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])
f='Score:'+str(d)
text=c.render(f,True,(0,0,0))
# 将果实画上去 # 将果实画上去
screen.blit(food, (ax, ay)) screen.blit(food, (ax, ay))
screen.blit(text,(489,0))
# 刷新画面 # 刷新画面
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