练习_最简弹球动画

1+

import turtle

turtle.shape('circle')
turtle.setup(480,360)
turtle.penup()
turtle.speed(0)

dx = 5
dy = 5
while True:    
    x = turtle.xcor()
    y = turtle.ycor()
    x = x + dx
    y = y + dy
    turtle.goto(x,y)    

    if abs(x) > 240 :dx = -dx        
    if abs(y) > 180 :dy = -dy
        
    

1+

发表评论