Commit 4c156670 by BellCodeEditor

save project

parent a0c8c9ed
Showing with 20 additions and 10 deletions
......@@ -49,37 +49,46 @@ while True:
# 设置贪吃蛇的头部坐标
if setheading == "right":
x +=30
x +=10
elif setheading == "left":
x -=30
x -=10
elif setheading == "up":
y -=30
y -=10
else:
y +=30
y +=10
position.append((x, y))
# 将背景图画上去
screen.blit(background, (0, 0))
# 将贪吃蛇的头画上去
screen.blit(snake_head, position[-1])
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
screen.blit(snake_head, position[-1])
info='SOCRE:'+str(s)+'!'
text=mf.render(info,True,(0,0,0))
screen.blit(text,(540,10))
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
if x==apple_x and y==apple_y:
t+=0.2
if s<5:
t+=0.2
if s>=5 and s<10:
t+=0.5
if s>=10 and s<20:
t+=0.7
if s>=20:
t+=1
s+=1
long=1
apple_x=random.randint(1,22)*30-30
apple_y=random.randint(1,16)*30-30
apple_x=random.randint(2,22)*30-30
apple_y=random.randint(2,16)*30-30
if long==0:
position.pop(0)
if x<0 or y<0 or x>630 or y>450:
exit()
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(t)
\ 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