import turtle
from random import randint
HEIGHT = 630
WEIGHT = 700
speed_value = 0
snowFlakes = []
ts = turtle.Screen()
ts.cv._rootwindow.resizable(False, False)
ts.setup(HEIGHT + 300, WEIGHT + 200)
turtle.bgpic('bg1.gif') # in the exe-file should have the path '_internal/bg1.gif'
turtle.tracer(2)
turtle.title('Snowflakes')
quantity_of_snowflakes = int(turtle.numinput('dialog box', 'Number of snowflakes', 10, minval = 3, maxval = 50))
wind_power = int(turtle.numinput('dialog box', 'Wind power', 2, minval = 0, maxval = 10))
for i in range(quantity_of_snowflakes):
flake = turtle.Turtle()
flake.penup()
flake.color('white')
flake.shape('circle')
flake.goto(randint(-WEIGHT, WEIGHT), HEIGHT)
flake.shapesize(randint(3, 12) / 10)
snowFlakes.append(flake)
snowFlakes.sort(key=lambda flake: flake.shapesize())
while True:
for flake in snowFlakes:
speed_value += 1
if flake.ycor() > -HEIGHT:
flake.goto(flake.xcor() + wind_power, flake.ycor() - speed_value)
elif flake.ycor() <= -HEIGHT:
flake.goto(randint(-WEIGHT, WEIGHT), HEIGHT)
flake.shapesize(randint(3, 12) / 10)
snowFlakes.sort(key=lambda flake: flake.shapesize()) #предпологаю что где-то тут ошибка
speed_value = 0