Commit 030ec7f3 by BellCodeEditor

save project

parent 668503c9
Showing with 8 additions and 1 deletions
......@@ -19,12 +19,14 @@ body = pygame.image.load('body.png') # 身体
left = pygame.image.load('left.png') # 头 朝左
up = pygame.image.load('up.png') # 头 朝上
down = pygame.image.load('down.png') # 头 朝下
myfont = pygame.font.Font("neuropol.ttf",20)
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
setheading = "right"
snake_head = right
fs = 0
while True:
for event in pygame.event.get():
......@@ -55,11 +57,13 @@ while True:
else:
y += 30
if apple_x == x and apple_y == y:
apple_x = random.randint(0,21)*30
apple_y = random.randint(0,15)*30
fs = fs + 10
else:
position.pop(0)
position.pop(0)
position.append((x, y))
......@@ -70,6 +74,9 @@ while True:
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
test = myfont.render("Score:"+str(fs),True,(0,0,0))
screen.blit(test,(510,30))
# 将果实画上去
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