Commit 8aea2bfc by BellCodeEditor

save project

parent 97f0a5ad
Showing with 27 additions and 0 deletions
import turtle
pen=turtle.Turtle()
pen.pencolor("black")
pen.speed(1)
pen.fillcolor("red")
pen.begin_fill()
pen.forward(180)
pen.left(90)
pen.forward(180)
pen.home()
pen.end_fill()
pen.setheading(0)
pen.fillcolor("yellow")
pen.begin_fill()
pen.forward(180)
pen.right(90)
pen.forward(180)
pen.fd(100)
pen.end_fill()
pen.setheading(0)
\ No newline at end of file
......@@ -60,8 +60,10 @@ while True:
if x==apple_x and y==apple_y:
num1=random.randint(1,22)
num2=random.randint(1,16)
score=+10
apple_x=30*num1-30
apple_y=30*num2-30
else:
position.pop(0)
position.append((x, y))
......@@ -72,6 +74,8 @@ while True:
# 将贪吃蛇的身体画上去
for i in range(len(position)-1):
screen.blit(body, position[i])
if x>0 or x<450 or y>0 or y>650:
ecid()
# 将果实画上去
screen.blit(food, (apple_x, apple_y))
......@@ -80,3 +84,4 @@ while True:
screen.blit(xx,(500,0))
pygame.display.update()
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