Пример #1
1
def main():
    points = [Point(x=230, y=450), Point(x=240, y=460), Point(x=230, y=470), Point(x=240, y=480)]
    polygon(point_list=points)
    points2 = [Point(p.x + 20, p.y + 20) for p in points]
    lines(point_list=points2, color=COLOR_DARK_ORANGE)
    line(start_point=Point(x=20, y=20), end_point=Point(x=40, y=300))
    square(left_bottom=Point(400, 300, ), side=100)
    rectangle(
        left_bottom=Point(x=200, y=200),
        right_top=Point(x=300, y=300),
        color=COLOR_DARK_GREEN
    )
    rectangle(
        left_bottom=Point(x=400, y=300),
        right_top=Point(x=300, y=400),
        color=COLOR_DARK_GREEN
    )
    sleep(2)
    clear_screen()
    vector(start=Point(x=230, y=260), angle=70, length=200, color=COLOR_PURPLE)
    for i in range(10):
        point = random_point()
        color = random_color()
        radius = random_number(20, 60)
        circle(center_position=point, radius=radius, color=color, width=0)
    sleep(2)
    clear_screen()
    for i in range(10):
        point = random_point()
        color = random_color()
        dx = random_number(30, 100)
        dy = random_number(30, 100)
        right_top = Point(x=point.x + dx, y=point.y + dy)
        ellipse(left_bottom=point, right_top=right_top, color=color)
    v3 = Vector(start_point=Point(0, 0), direction=45, length=50)
    for direction in range(0, 181, 20):
        v = Vector(start_point=Point(x=300, y=300), direction=direction, length=100)
        v.draw()
        v2 = Vector(start_point=v.end_point, direction=direction + 30, length=50)
        v2.draw(color=COLOR_GREEN)
        v2.add(v3)
        v2.draw(color=COLOR_ORANGE)
    snowflake(center=Point(), length=60, factor_b=0.2, factor_c=100)
    sleep(2)
    for k in range(2):
        y = 500
        for i in range(10):
            clear_screen()
            y -= 30
            for x in [100, 200, 300, 400, 500]:
                radius = random_number(30, 50)
                point = Point(x=x, y=y)
                snowflake(center=point, length=radius)
                mouse_point, mouse_buttons = get_mouse_state()
                print("mouse_state is {} + {}".format(mouse_point, mouse_buttons))
            if user_want_exit(sleep_time=0.1):
                break
        if user_want_exit(0):
            break
Пример #2
0
def show_bubble(bub_center, bub_radius=20):
    ''' draws the bubble then removes it by background color'''
    draw_bubble(bub_center=bub_center, bub_radius=bub_radius)
    sd.sleep(0.05)
    draw_bubble(bub_center=bub_center,
                bub_radius=bub_radius,
                bub_color=sd.background_color)
Пример #3
0
def draw_sun(x, y, length):
    global angle
    radius = length // 2
    sd.start_drawing()
    sd.vector(sd.get_point(x, y),
              angle=angle,
              length=length,
              color=sd.background_color,
              width=3)
    angle += 30
    sd.vector(sd.get_point(x, y),
              angle=angle,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.vector(sd.get_point(x, y),
              angle=angle + 30,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.vector(sd.get_point(x, y),
              angle=angle + 60,
              length=length,
              color=(255, 255, 0),
              width=3)
    sd.finish_drawing()
    sd.circle(sd.get_point(x, y), radius=radius, width=0)
    sd.sleep(0.01)
Пример #4
0
def snowfall(N):
    snowflake = []
    for _ in range(N):
        snowflake.append(([sd.random_number(-50, 1250), sd.random_number(550, 1600), sd.random_number(23, 47)]))

    while True:
        sd.start_drawing()
        for snow in snowflake:
            x, y, length = snow
            point = sd.get_point(x, y)

            sd.snowflake(center=point, length=length, color=sd.background_color, factor_a=0.6)
            if y > 50:
                snow[1] -= 10
                snow[0] -= 10
                point_fall = sd.get_point(x, y)
                sd.snowflake(point_fall, length=length, color=sd.COLOR_WHITE)
            else:
                last_point = sd.get_point(x, y - 1)
                sd.snowflake(last_point, length, color=sd.COLOR_WHITE)
                snow[1] += 1250

        sd.finish_drawing()
        sd.sleep(0.05)
        if sd.user_want_exit():
            break
        sd.clear_screen()
Пример #5
0
def falling():
    while True:
        sd.start_drawing()
        for i in range(N - 1):
            size = size_list[i]

            sd.snowflake(center=sd.get_point(x=x_list[i], y=y_list[i]),
                         length=size,
                         color=sd.background_color)
            y_list[i] -= speed_list[i]
            sd.snowflake(center=sd.get_point(x=x_list[i], y=y_list[i]),
                         length=size,
                         color=sd.COLOR_WHITE)
            if y_list[i] < 40:
                y_list[i] = 600
            point1 = sd.get_point(x_list[i], y_list[i])
            sd.snowflake(center=point1,
                         length=size,
                         color=sd.COLOR_WHITE,
                         factor_a=0.6,
                         factor_b=0.35,
                         factor_c=60)
            sd.sleep(0.001)

        sd.finish_drawing()

        if sd.user_want_exit():
            break
def snowfall(coord_x=0, coord_y=500):
    count_snowfall = 20

    x = []
    for _ in range(count_snowfall):
        x.append(sd.random_number(coord_x, coord_y))
    y = []
    for _ in range(count_snowfall):
        y.append(sd.random_number(coord_x, coord_y))

    while True:
        sd.start_drawing()
        for i in range(len(x)):
            if i > 0:
                point1 = sd.get_point(x[i - 1], y[i - 1])
                sd.snowflake(center=point1, length=10, color=sd.COLOR_WHITE)
            point = sd.get_point(x[i], y[i])
            if y[i] > 50:
                sd.snowflake(center=point,
                             length=10,
                             color=sd.background_color)
                y[i] -= sd.random_number(-1, 15)
                x[i] = x[i] + sd.random_number(-15, 15)
        sd.finish_drawing()
        sd.sleep(0.1)
Пример #7
0
def snowfall1(n=5):
    quantity_snowflakes = n
    snowflake_dict = {}
    for number_x in range(quantity_snowflakes):
        x = sd.random_number(50, 100)
        y = sd.random_number(800, 850)
        length = sd.random_number(5, 15)
        snowflake_dict[number_x] = [x, y, length]

    while True:
        sd.start_drawing()
        for sf_name, value in snowflake_dict.items():
            x = value[0]
            y = value[1]
            length = value[2]
            point = sd.get_point(x, y)
            sd.snowflake(center=point,
                         length=length,
                         color=sd.background_color)
            value[0] += sd.random_number(-5, 5)
            value[1] -= sd.random_number(5, 20)
            point2 = sd.get_point(value[0], value[1])
            sd.snowflake(center=point2, length=length)
            if value[1] < 60:
                value[0] = sd.random_number(50, 100)
                value[1] = value[1] + 800
        sd.finish_drawing()
        sd.sleep(0.1)
Пример #8
0
def show_snow(count_flake):
    snow_params = []

    for _ in range(count_flake):
        snow_params.append([sd.random_number(0, 1000), sd.random_number(500, 600), sd.random_number(20, 40)])

    while True:
        for flake in snow_params:
            x, y, length = flake
            draw_flake(x, y, length, sd.COLOR_WHITE)

        sd.finish_drawing()
        sd.sleep(0.1)

        for key, flake in enumerate(snow_params):
            x, y, length = flake
            draw_flake(x, y, length, sd.background_color)

            snow_params[key][0] += sd.random_number(-25, 25)
            snow_params[key][1] -= sd.random_number(1, 25)

        if y < 0:
            break

        if sd.user_want_exit():
            break
def falling_snowflake():
    snowflakes_length = [sd.random_number(10, 101) for _ in range(20)]
    snowflakes_point = {
        i: [sd.random_number(0, 500), 500, i]
        for i in range(20)
    }
    old_points_arr = [[snowflakes_point[key][0], snowflakes_point[key][1]]
                      for key, val in snowflakes_point.items()]
    while True:
        sd.start_drawing()
        for i in range(20):
            if len(old_points_arr) < 20:
                sd.snowflake(center=old_points_arr[i],
                             length=snowflakes_length[i],
                             color=sd.background_color)
            x, y, delay = snowflakes_point[i]
            if delay < 1:
                point = sd.get_point(x, y)
                sd.snowflake(center=sd.Point(old_points_arr[i][0],
                                             old_points_arr[i][1]),
                             length=snowflakes_length[i],
                             color=sd.background_color)
                sd.snowflake(center=point, length=snowflakes_length[i])
                if y < 20:
                    snowflakes_point[i][1] = 500
                    continue
                snowflakes_point[i][1] -= 9
                snowflakes_point[i][0] += sd.random_number(-10, 10)
                old_points_arr[i] = [x, y]
            snowflakes_point[i][2] -= .2
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Пример #10
0
def snowflake():
    ground_level = 50
    k = 0
    while True:
        sd.start_drawing()
        for i in snowflakes_param:
            x = i[0]
            y = i[1]
            point = sd.get_point(x, y)
            snowflake_length = i[2]
            sd.snowflake(center=point,
                         length=snowflake_length,
                         color=sd.background_color)
            i[1] -= sd.random_number(0, 20)
            i[0] += sd.random_number(-20, 20)
            point_1 = sd.get_point(i[0], i[1])
            sd.snowflake(center=point_1,
                         length=snowflake_length,
                         color='white')
            if y < ground_level:
                ind = snowflakes_param.index(i)
                fallen.append(snowflakes_param.pop(ind))
                flake_add(snowflakes_param, 1)
                k += 1
        if k >= 10:
            ground_level += 5
            k = 0
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Пример #11
0
def snowflakes(_x1, _y1, _x2, _y2):
    def new_snowflake():
        _x = sd.random_number(_x1, _y1)
        _y = sd.random_number(_x2, _y2)
        _length = sd.random_number(10, 20)
        _my_dict = {'x': _x, 'y': _y, 'length': _length}
        snowflakes[i] = _my_dict

    snowflakes = {}

    for i in range(50):
        new_snowflake()

    while True:
        sd.start_drawing()
        for i, snowflake in snowflakes.items():

            sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']), length=snowflake['length'],
                         color=sd.background_color)
            snowflake['y'] -= 10
            if snowflake['x'] >= 340:
                snowflake['x'] += sd.random_number(-51, -50)
            snowflake['x'] += sd.random_number(-50, 50)
            sd.snowflake(center=sd.get_point(snowflake['x'], snowflake['y']), length=snowflake['length'],
                         color=sd.COLOR_WHITE)
            if snowflake['y'] < snowflake['length']:
                new_snowflake()
                continue
            sd.sleep(0.005)

        sd.finish_drawing()
        if sd.user_want_exit():
            break
    sd.pause()
Пример #12
0
def snowfall():
    flakes = dict(x=[], y=[], size=[])

    for i in range(N):
        flakes['x'].append(sd.random_number(0, sd.resolution[0] // 5))
        flakes['y'].append(sd.random_number(sd.resolution[1] - 400, sd.resolution[1] - 200))
        flakes['size'].append(sd.random_number(5, 30))

    while True:
        sd.start_drawing()
        if 'points' in locals():
            for index in range(N):
                sd.snowflake(center=points[index], length=flakes['size'][index], color=sd.background_color)
        points = []
        for index in range(N):
            point = sd.get_point(flakes['x'][index], flakes['y'][index])
            points.append(point)
            sd.snowflake(center=point, length=flakes['size'][index])
            if flakes['y'][index] > sd.random_number(130, 160):
                flakes['y'][index] -= sd.random_number(2, 10)
                flakes['x'][index] += sd.random_number(-5, 5)

        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Пример #13
0
def snow(y_drop):
    drift = 5

    sd.start_drawing()

    for snowflake in range(N):
        point = sd.get_point(x_coordinates_list[snowflake],
                             y_coordinates_list[snowflake])
        sd.snowflake(center=point,
                     length=length_list[snowflake],
                     color=sd.background_color)
        if y_coordinates_list[snowflake] > drift and x_coordinates_list[
                snowflake] < 300:
            y_coordinates_list[snowflake] -= y_drop
            random_vector = sd.random_number(-8, 8)
            if length_list[snowflake] < 35:
                x_coordinates_list[snowflake] = x_coordinates_list[
                    snowflake] + random_vector * 1.4
            else:
                x_coordinates_list[
                    snowflake] = x_coordinates_list[snowflake] + random_vector
            point_new = sd.get_point(x_coordinates_list[snowflake],
                                     y_coordinates_list[snowflake])
            sd.snowflake(center=point_new, length=length_list[snowflake])
        else:
            sd.snowflake(center=point, length=length_list[snowflake])
            x_coordinates_list[snowflake] = sd.random_number(30, 200)
            y_coordinates_list[snowflake] = sd.random_number(500, 900)
            length_list[snowflake] = sd.random_number(1, 10)
            drift += 0.1

    sd.finish_drawing()

    sd.sleep(0.02)
def snow():
    x_list = []
    y_list = []
    flake_length_list = []
    number_of_snowflakes = 20
    for _ in range(number_of_snowflakes):
        x_list.append(sd.random_number(0, sd.resolution[0]))
        y_list.append(sd.random_number(sd.resolution[1], sd.resolution[1] * 2))
        flake_length_list.append(sd.random_number(20, 50))
    while True:
        sd.start_drawing()
        for x, y, length, i in zip(x_list, y_list, flake_length_list,
                                   range(number_of_snowflakes)):
            if y_list[i] > 65:
                sd.snowflake(sd.get_point(x, y),
                             length,
                             color=sd.background_color)
            x_list[i] += sd.random_number(-15, 15)
            y_list[i] -= sd.random_number(4, 30)
            if y_list[i] < 50:
                y_list[i] = sd.random_number(sd.resolution[1],
                                             sd.resolution[1] * 2)
            sd.snowflake(sd.get_point(x_list[i], y_list[i]), length)
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Пример #15
0
def snowflakes(quantity):
    x_list = []
    y_list = []
    size_list = []
    length_list = []
    for _ in range(quantity):
        new_x = sd.random_number(50, 1150)
        x_list.append(new_x)
        new_y = sd.random_number(0, 600)
        y_list.append(new_y)
        new_size = sd.random_number(10, 40)
        size_list.append(new_size)
        new_length = round(sd.random_number(10, 90) / 100, 1)
        length_list.append(new_length)
    while True:
        sd.start_drawing()
        sd.clear_screen()
        for i, x in enumerate(x_list):
            if y_list[i] < 0:
                y_list[i] = 600
            point = sd.get_point(x_list[i], y_list[i])
            sd.snowflake(center=point, length=size_list[i], factor_b=length_list[i])
            y_list[i] -= 10
        sd.finish_drawing()
        sd.sleep(0.1)
        if sd.user_want_exit():
            break
Пример #16
0
def main():
    sd.start_drawing()
    plain.render(color=COLOR, need_edge=True)
    sd.finish_drawing()
    sd.sleep(5)
    rotate_paper(360, 240)

    sd.pause()
Пример #17
0
def apples(color):
    for x in range(850, 1250, 100):
        point = sd.get_point(x=x, y=350)
        sd.circle(center_position=point, radius=15, color=sd.COLOR_GREEN, width=0)
        sd.sleep(0.05)
        sd.circle(center_position=point, radius=15, color=color, width=0)

    sd.finish_drawing()
Пример #18
0
def act_nine():
    for deg in range(40):
        sd.start_drawing()
        clear_screen()
        plain.rotateY(angle_deg=2)
        plain.render(color=COLOR, color_back=COLOR_BACK, need_edge=True)
        sd.finish_drawing()
        sd.sleep(0.1)
Пример #19
0
def rotate_paper(angle, steps):
    angle = angle / steps
    for _ in range(steps):
        sd.start_drawing()
        clear_screen()
        plain.rotateY(angle)
        plain.render(color=COLOR, need_edge=True)
        sd.finish_drawing()
        sd.sleep(0.05)
Пример #20
0
def snowfall_main():
    n = 20
    # Переменная length_of_snowflake не используется.
    # length_of_snowflake = sd.random_number(10, 100)
    snowflakes = []
    #  Переменная snowflake не используется.
    # snowflake = []

    # генерация списка из 20 снежинок
    for quantity_snowflakes in range(n):
        x = sd.random_number(50, 100)
        y = sd.random_number(720, 800)
        length_of_snowflake = sd.random_number(10, 25)
        snowflake = [x, y, length_of_snowflake]
        snowflakes.append(snowflake)

    while True:
        sd.start_drawing()

        for i, (x, y, length) in enumerate(snowflakes):

            if y < 0:
                # Если высота падения снежинки становится меньше нуля,то:
                point = sd.get_point(x, y)
                sd.snowflake(center=point,
                             length=length,
                             color=sd.background_color)
                x = sd.random_number(
                    50, 100)  # генерация новой координаты х для новой снежинки
                y = sd.random_number(
                    720,
                    800)  # генерация новой координаты у для новой снежинки
                length_of_snowflake = sd.random_number(
                    10, 25)  # генерация новой длины для новой снежинки
                snowflake = [x, y, length_of_snowflake
                             ]  # генерация новой снежинки, взамен удаленной
                snowflakes[i] = snowflake  # замена снежинки по индексу
                break
            point = sd.get_point(x, y)

            sd.snowflake(center=point,
                         length=length,
                         color=sd.background_color)

            x += sd.random_number(-10, 10)
            y -= sd.random_number(1, 5)

            snowflakes[i] = [x, y, length]
            point2 = sd.get_point(x, y)
            sd.snowflake(center=point2, length=length, color=sd.COLOR_WHITE)

        sd.finish_drawing()

        sd.sleep(0.05)

        if sd.user_want_exit():
            break
Пример #21
0
 def draw_items(self):
     sd.start_drawing()  # removes  blinking
     for statObj in self.static_objects:
         statObj.draw_item()
     for dinObj in self.mobile_objects:
         dinObj.draw_item()
     sd.finish_drawing()  # removes  blinking
     sd.sleep(0.06)
     sd.draw_background()
Пример #22
0
def rotate_paper(angle, steps):
    angle = angle / steps
    for _ in range(steps):
        sd.start_drawing()
        clear_screen()
        plain.rotate(angle)
        plain.render(color=COLOR, color_back=COLOR_BACK)
        sd.finish_drawing()
        sd.sleep(0.05)
Пример #23
0
def falling():
    x = 50
    while True:
        snowflakes(N=8, y_shift=x)
        sd.sleep(0.1)
        snowflakes(N=8, y_shift=x, color=sd.background_color)

        x -= 50
        if sd.user_want_exit():
            break
Пример #24
0
 def fall(self):
     while True:
         self.clear_previous_picture()
         self.move()
         self.draw()
         if self.cant_fall():
             break
         sd.sleep(0.1)
         if sd.user_want_exit():
             break
Пример #25
0
def snowfall(n):
    speed, coord, length = [], [], []
    for i in range(n):
        speed.append(random.randint(10, 50))
        x = random.randint(10, 250)
        y = random.randint(300, 350)
        coord.append([x, y])
        length.append(random.randint(5, 10))

    while True:
        for i in range(n):
            sd.start_drawing()
            wind = random.randint(-20, 20)

            point = sd.get_point(coord[i][0], coord[i][1])
            sd.snowflake(center=point,
                         length=length[i],
                         color=sd.background_color)
            coord[i][0] -= wind
            coord[i][1] -= speed[i]

            x0, y0 = coord[i][0], coord[i][1]
            point = sd.get_point(x0, y0)
            sd.snowflake(center=point, length=length[i])

            if coord[i][1] <= 20 and speed != 0:
                speed[i] = 0
                coord[i].pop()
                coord[i].pop()

            sd.finish_drawing()

            if speed[i] == 0:
                speed.pop(i)
                speed.insert(i, random.randint(5, 30))

            if len(coord[i]) == 0:
                length.pop(i)
                length.insert(i, random.randint(5, 10))
                coord.remove([])
                x = random.randint(10, 250)
                y = random.randint(300, 350)
                coord.insert(i, [x, y])

        sd.sleep(0.1)
        if sd.user_want_exit():
            break
    # sd.pause()


# def main():
#     snowfall(10)

# main()
Пример #26
0
def for_painting(length):
    x_list = []
    y_list = []
    N = 50

    for x in range(0, N - 1):
        k = sd.random_number(0, 300)
        x_list.insert(x, k)

    for y in range(0, N - 1):
        k = sd.random_number(600, 800)
        y_list.insert(y, k)

    for i in range(N - 1):
        x = x_list[i]
        y = y_list[i]

        while True:
            sd.start_drawing()
            sd.snowflake(center=sd.get_point(x, y),
                         length=length,
                         color=sd.background_color)

            y -= 20

            sd.snowflake(center=sd.get_point(x, y),
                         length=length,
                         color=sd.COLOR_WHITE)

            sd.sleep(0.005)

            if 0 <= i < N - 30:
                if y < 75:
                    y = 70
                    break
            elif N - 30 <= i < N - 20:
                if y < 95:
                    y = 90
                    break
            elif N - 20 <= i < N - 12:
                if y < 111:
                    y = 110
                    break
            elif N - 12 <= i < N - 5:
                if y < 121:
                    y = 120
                    break
            elif N - 5 <= i < N:
                if y < 141:
                    y = 140
                    break
            sd.finish_drawing()
            if sd.user_want_exit():
                break
Пример #27
0
def snowfall():
    list = []
    N = 20
    for i in range(N):
        local = [sd.random_number(400, 600), sd.random_number(100, 300)]
        list.append(local)

    while True:

        #sd.clear_screen()
        lenght = sd.random_number(10, 70)
        for item in list:
            sd.start_drawing()
            point = sd.get_point(item[1], item[0])

            sd.snowflake(center=point,
                         length=lenght,
                         color=sd.background_color)

            item[0] -= sd.random_number(-20, 50)
            if item[0] < 50:
                point = sd.get_point(item[1], item[0])
                sd.snowflake(center=point, length=lenght, color=sd.COLOR_WHITE)

            item[1] = item[1] + sd.random_number(1, 50)
            point = sd.get_point(item[1], item[0])
            sd.snowflake(center=point, length=lenght, color=sd.COLOR_WHITE)

            sd.finish_drawing()
            sd.sleep(0.01)

        if sd.user_want_exit():
            break

    sd.pause()


# подсказка! для ускорения отрисовки можно
#  - убрать clear_screen()
#  - в начале рисования всех снежинок вызвать sd.start_drawing()
#  - на старом месте снежинки отрисовать её же, но цветом sd.background_color
#  - сдвинуть снежинку
#  - отрисовать её цветом sd.COLOR_WHITE на новом месте
#  - после отрисовки всех снежинок, перед sleep(), вызвать sd.finish_drawing()

# 4) Усложненное задание (делать по желанию)
# - сделать рандомные отклонения вправо/влево при каждом шаге
# - сделать сугоб внизу экрана - если снежинка долетает до низа, оставлять её там,
#   и добавлять новую снежинку
# Результат решения см https://youtu.be/XBx0JtxHiLg

#зачет!
Пример #28
0
def snowfall():
    x_snow = []
    y_snow = []
    len_snow = []
    coin_iteration = []
    coin_snow = 10  # количество снежинок
    speed_snow = []
    for i in range(coin_snow - 1):
        x_snow.insert(i, randint(
            20,
            600))  # первоначальное размещение снежинок вверху по горизонтали
        y_snow.insert(i, 830)  # высота первоначального размещения снежинок
        len_snow.insert(i, randint(10, 30))  # длина лучей снежинки
        speed_snow.insert(i, randint(
            1, 10))  #  смещение снежинки вниз на каждом шаге
        coin_iteration.insert(i, 3)  # количество падений каждой снежинки

    def snow_draw(x, y, len):  #  отрисовка снежинки
        point = sd.get_point(x, y)
        sd.snowflake(center=point, length=len)

    def snow_clear(x, y, len):  #  закрашивание снежинки
        point = sd.get_point(x, y)
        color_clear = sd.background_color
        sd.snowflake(center=point, length=len, color=color_clear)

    while True:
        for i in range(coin_snow - 1):
            snow_clear(x=x_snow[i], y=y_snow[i], len=len_snow[i])
            # sd.sleep(0.1)
            if y_snow[i] <= 30:  # высота на которой снежинка останавливается
                snow_draw(x=x_snow[i], y=y_snow[i], len=len_snow[i])
                coin_iteration[i] -= 1
                x_end, y_end, len_end = x_snow, y_snow, len_snow
                x_snow[i] = randint(20, 600)
                y_snow[i] = 830
                len_snow[i] = randint(10, 30)
                speed_snow[i] = randint(1, 10)
                if coin_iteration[i] <= 0:
                    speed_snow[i] = 0
                    x_snow, y_snow, len_snow = x_end, y_end, len_end
            y_snow[i] -= speed_snow[i]
            snow_draw(x=x_snow[i], y=y_snow[i], len=len_snow[i])
            # sd.sleep (0.1)
        # print('coin_iteration - ', coin_iteration)
        # print('speed_snow - ', speed_snow)
        # print(set(speed_snow))
        if sd.user_want_exit():
            break
        if set(speed_snow) == {0}:
            sd.sleep(3)
            break
Пример #29
0
def fitness():
    start_angle1 = 0
    start_angle2 = 0
    while True:
        sd.start_drawing()
        fn.arm(color1=sd.background_color,
               color2=sd.background_color,
               color3=sd.background_color,
               angle1=start_angle1,
               angle2=start_angle2)
        if (start_angle1 + 0.5) % 45 < 0.9:
            start_angle1 = start_angle1 - 0.4
        else:
            start_angle1 = start_angle1 - 0.2
        if (start_angle2 + 0.5) % 45 < 0.9:
            start_angle2 = start_angle2 + 0.8
        else:
            start_angle2 = start_angle2 + 0.4
        fn.arm(color1=(169, 169, 169),
               color2=(105, 105, 105),
               color3=(244, 164, 96),
               angle1=start_angle1,
               angle2=start_angle2)
        sd.finish_drawing()
        sd.sleep(0.01)
        if start_angle2 - start_angle1 > 130:
            break

    while True:
        sd.start_drawing()
        fn.arm(color1=sd.background_color,
               color2=sd.background_color,
               color3=sd.background_color,
               angle1=start_angle1,
               angle2=start_angle2)
        if (start_angle1 + 0.5) % 45 < 0.9:
            start_angle1 = start_angle1 + 0.4
        else:
            start_angle1 = start_angle1 + 0.2
        if (start_angle2 + 0.5) % 45 < 0.9:
            start_angle2 = start_angle2 - 0.8
        else:
            start_angle2 = start_angle2 - 0.4
        fn.arm(color1=(169, 169, 169),
               color2=(105, 105, 105),
               color3=(244, 164, 96),
               angle1=start_angle1,
               angle2=start_angle2)
        sd.finish_drawing()
        sd.sleep(0.01)
        if start_angle2 - start_angle1 < 0:
            break
Пример #30
0
def show_bubbles_cloud(b_cloud=[]):
    ''' draws all bubbles in list then removes them'''
    if not b_cloud:
        return
    sd.take_background()
    sd.start_drawing()  # removes  blinking
    for bubble in b_cloud:
        point = sd.get_point(bubble['x'], bubble['y'])
        draw_bubble(point, bubble['r'], bub_color=bubble['col'])
    sd.finish_drawing()  # removes  blinking
    sd.sleep(0.05)
    sd.draw_background()
    return
Пример #31
0
def animation():
    raindbow()
    brick_wall()
    window()
    roof()
    smile_face()
    threes()
    sd.take_background()
    while True:
        snowflake_drop()
        animation_sun(angle=angle)
        raindbow_animation()
        sd.sleep(0.1)
Пример #32
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# нарисовать снегопад - 7 движужихся снежинок радиусом от 10 до 60 
# снежинки падают с высоты 500 пикселов со скоростью 30 пикселов за такт
# на расстоянии 100 пикселов друг от друга
from simple_draw import clear_screen, Point, snowflake, sleep, end

y = 500
for i in range(10):
    clear_screen()
    y = ...  # как изменяется y для всех снежинок
    for i in range(7):
        point = Point(...)
        snowflake(point)
    sleep(0.3)

# + нарисовать снежинки разных радиусов, для этого хранить список радиусов
radiuses = [30, 20, 40, 10, 50, 70, ]

# + сделать скорость падения уникальной для каждой снежинки,
# для этого хранить список координат Y и скоростей по Y
coordinates = [...]
velocity = [...]

# ++ сделать реальный снегопад, что бы снежинки порхали из стороны в сторону

end()