Commit 12762a65 by BellCodeEditor

auto save

parent f7977280
Showing with 39 additions and 6 deletions
import turtle
turtle.speed(1)
turtle.penup()
turtle.goto(-100,100)
turtle.pendown()
for i in range(4):
turtle.forward(200)
turtle.right(90)
turtle.goto(0,100)
turtle.color("black","red")
turtle.begin_fill()
turtle.goto(100,0)
turtle.goto(0,-100)
turtle.goto(-100,0)
turtle.goto(0,100)
turtle.end_fill()
turtle.hideturtle()
turtle.done()
\ No newline at end of file
a=int(input("乌龟爬行的速度:"))
b=100/a
print("乌龟能够追上兔子的时间为:",b,"秒",sep="")
# a=float(input("输入半径:"))
# pi=3.14
# print("圆的周长是%.2f,面积是%.2f"%(2*pi*a,pi*a**2))
# print("圆的周长是{:.2f},面积是{:.2f}".format(2*pi*a,pi*a**2))
a=10
print(eval('a+10'))
\ No newline at end of file
......@@ -13,6 +13,7 @@ right = pygame.image.load('right.png')
food = pygame.image.load('apple.png')
body = pygame.image.load('body.png')
x,y=240, 120
pos=[(180, 90),(180, 120),(210, 120),(x,y)]
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
......@@ -20,15 +21,18 @@ while True:
exit()
# 将背景图画上去
x+=30
pos.append((x,y))
pos.pop(0)
screen.blit(background, (0, 0))
# 将贪吃蛇画上去
screen.blit(right, (x, y))
screen.blit(right, pos[-1])
# 将贪吃蛇的身体画上去
screen.blit(body, (210, 120))
screen.blit(body, (180, 120))
screen.blit(body, (180, 90))
for i in range(len(pos)-1):
screen.blit(body, pos[i])
# screen.blit(body, (180, 120))
# screen.blit(body, (180, 90))
# 将果实画上去
screen.blit(food, (360, 300))
# 刷新画面
pygame.display.update()
a.tick(100)
\ No newline at end of file
a.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