海龟作图,沙盒弹珠(小球)碰撞演示
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/2413f87bcb35f08f66af27cb549174fe.png)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e4c2c2b7f019a4b1747c2e9c7587302f.png)
import turtle
from random import randint
import time
w,h = 500,400
screen = turtle.Screen()
screen.delay(0)
screen.bgcolor('black')
screen.setup (w,h)
screen.title("沙盒弹珠碰撞演示,作者:childoge")
draw = turtle.Turtle()
draw.penup()
draw.goto(-w/2,-h/2)
draw.pencolor('white')
draw.pensize(6)
draw.fillcolor('white')
draw.down()
draw.begin_fill()
for i in range(2):
draw.forward(w)
draw.left(90)
draw.forward(h)
draw.left(90)
draw.hideturtle()
draw.end_fill()
class Ball():
def __init__(self,name,color,xspeed,yspeed):
self.name = turtle.Turtle(shape