Commit 2c3dbe13 by BellCodeEditor

save project

parent c7e1c053
Showing with 6 additions and 2 deletions
......@@ -16,13 +16,15 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下
my_font=pygame.font.Font('neuropol.ttf',20)
apple_x,apple_y=240,120
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
score=0
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -56,6 +58,7 @@ while True:
if apple_x==x and apple_y==y:
apple_x=random.randint(0,21)*30
apple_y=random.randint(0,15)*30
score+=10
else:
position.pop(0)
screen.blit(background, (0, 0))
......@@ -64,8 +67,9 @@ while True:
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
text=my_font.render('score:'+str(score),False,(255,0,0))
# 将果实画上去
screen.blit(text,(490,20))
screen.blit(food, (apple_x, apple_y))
# 刷新画面
pygame.display.update()
......
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