Ejemplo n.º 1
0
stern_of_ship = objects_of_ship_2[0]
ship_length = 237


def keyPressed(event):
    pause = 5
    time.sleep(pause)
    g.close()


def update():
    for object_ in objects_of_ship_2:
        g.moveObjectBy(object_, dx, 0)

    g.penColor('white')
    g.brushColor('white')
    g.rectangle(0, 0, frame_thickness, window_height)
    g.rectangle(window_width - frame_thickness, 0, window_width, window_height)

    if g.xCoord(stern_of_ship) > window_width:
        for object_ in objects_of_ship_2:
            g.moveObjectBy(object_, -window_width - ship_length, 0)


dx = 3
update_time_ms = 50
g.onKey(keyPressed)
g.onTimer(update, update_time_ms)

g.run()
Ejemplo n.º 2
0
def update():

    for dot in objects.dots:

        if objects.brusochek.p != 0:

            dot.circleInWindow()

            objects.cirleMov()

            objects.mklable()

            if dot.getPosition('y') + dot.radius(
            ) >= height + radius:  # условие проигрыша
                graph.close()

        else:  # фиксация шарика над платформой
            graph.moveObjectTo(
                dot.object,
                objects.brusochek.position_update() +
                objects.brusochek.width / 2,
                dot.getPosition('y') - dot.radius())
            dot.setPosition(graph.xCoord(dot.object),
                            objects.brusochek.y - dot.radius() * 4)


graph.onKey(mov)
graph.onTimer(update, 10)
graph.run()
Ejemplo n.º 3
0
            rows += 1
            p += 350
        lines += 1
        rows = 0
        p = -200
        o += 400
    return marlin


def changeColor():
    global angle
    for z in marlin:
        changeFillColor(z, randColor())


def rotateMarlin():
    global angle
    for s in marlin:
        moveObjectBy(s, 0.5 * math.cos(angle), 0.5 * math.sin(angle))
    if angle <= 2 * math.pi:
        angle += 0.005
    else:
        angle = 0


marlin = draw_marlin()
onTimer(rotateMarlin, 1)
onTimer(changeColor, 500)

run()
Ejemplo n.º 4
0
                       (291 / r + x, 208 / r + y), (285 / r + x, 209 / r + y),
                       (281 / r + x, 202 / r + y),
                       (278 / r + x, 191 / r + y)]))
    pand.append(
        graph.polygon([(404 / r + x, 187 / r + y), (409 / r + x, 191 / r + y),
                       (411 / r + x, 201 / r + y), (411 / r + x, 219 / r + y),
                       (407 / r + x, 239 / r + y), (398 / r + x, 256 / r + y),
                       (379 / r + x, 275 / r + y), (368 / r + x, 273 / r + y),
                       (353 / r + x, 263 / r + y), (362 / r + x, 235 / r + y),
                       (382 / r + x, 206 / r + y), (397 / r + x, 190 / r + y),
                       (404 / r + x, 187 / r + y)]))
    return pand


graph.brushColor(255, 175, 128)  # Фон
graph.rectangle(0, 0, 500, 333)
global animal
animal = panda()
panda(4, 150, 200)
plant(1, 0, 1, 0)
plant(0.322, 89.7, 0.707, 71)
plant(0.35, 0, 0.707, 60)
plant(0.35, 350, 1, 0)
print(type(animal))
for obj in animal:
    print(type(obj))

graph.onTimer(update, 50)
graph.onKey(KeyPressed)
graph.run()
Ejemplo n.º 5
0
graph.brushColor("#fed5c4")
graph.rectangle(0, 200, 1200, 400)
graph.brushColor("#fed594")
graph.rectangle(0, 400, 1200, 600)
graph.brushColor("#b38694")
graph.rectangle(0, 600, 1200, 800)


def update():
    for i in range(1, 11):
        x = 1.1**i
        y = 3 * i
        graph.moveObjectBy(obj, x, y)


graph.onTimer(update, 20)

graph.penColor("#fc9831")
graph.brushColor("#fc9831")
graph.polygon([(250, 250), (500, 300), (0, 400)])
graph.polygon([(850, 150), (1200, 200), (700, 300)])

graph.penColor("red")
graph.brushColor("red")
graph.circle(600, 500, 50)
graph.polygon([(0, 600), (300, 400), (600, 550)])
graph.polygon([(600, 550), (850, 400), (1200, 500)])

x = 20
y = 10
x0 = y0 = 100
bird3 = bird(scale=2, angle=0.1)
bird4 = bird(scale=1, angle=-0.05)
bird5 = bird(scale=0.5, angle=0.04)
bird6 = bird(scale=1, angle=-0.02)
birds = [bird1, bird2, bird3, bird4, bird5, bird6]
move_by(bird1, 100, 100)
move_by(bird2, 530, 130)
move_by(bird3, 260, 170)
move_by(bird4, 130, 450)
move_by(bird5, 410, 200)
move_by(bird6, 500, 210)
move_by(bird(scale=2, angle=0.26), 290, 290)
move_by(bird(scale=2.5, angle=0.3), 490, 390)
move_by(bird(scale=0.3, angle=-0.1), 50, 190)


def timerfun():
    move_by(sw1, randint(-2, 6), randint(-4, 2))
    move_by(sw2, -0.1, -0.4)
    move_by(sw3, 0.5, 0.5)
    move_by(fish1, 0.5, 0)
    move_by(fish2, 0.3, 0.05)
    move_by(fish3, 0.7, 0.2)
    for birdi in birds:
        move_by(birdi, randint(-1, 1), randint(-3, 3))


onTimer(timerfun, 100)

run()
Ejemplo n.º 7
0
brushColor("#c7fcec")
rectangle(0, 0, 500, 300)

dom(0, 0, 0, 0, 0)
brushColor(176, 196, 222)
a = ghost(-100, -100, 33, 232, 33)
penColor(255, 255, 254)
brushColor(255, 255, 254)
circle(460, 50, 40)
el(370, 170, 0, 255, 255)
el(350, 70, 10, 243, 30)
el(250, 50, 20, 255, 255)
penColor(0, 0, 0)
brushColor(0, 0, 0)
c = circle(257, 250, 1)
s = circle(264, 250, 1)


def update():
    moveObjectBy(a, 1, 1)
    moveObjectBy(c, 1, 1)
    moveObjectBy(s, 1, 1)
    changeFillColor(a, randColor())
    if xCoord(a) >= 500:
        close()


onTimer(update, 50)

run()
Ejemplo n.º 8
0
g.brushColor("black")
body = g.polygon([(125, 500), (125, 300), (200, 300), (200, 500)])

# head
g.brushColor(255, 168, 85)
g.penColor(255, 168, 85)
head = g.circle(163, 280, 30)

# mouth
dm = 4
g.penColor("black")
mouth = g.circle(163, 290, dm)

# eyes
g.penSize(10)
leye = g.point(153, 270, "black")  # left
reye = g.point(173, 270, "black")  # right

# hands
g.penSize(1)
g.penColor("black")
g.brushColor(255, 168, 85)
lhand = g.polygon([(140, 315), (130, 280), (140, 275), (150, 310)])  # left
lh = [(140, 315), (130, 280), (140, 275), (150, 310)]
rhand = g.polygon([(176, 310), (186, 315), (196, 280), (183, 275)])  # right
rh = [(176, 310), (186, 315), (196, 280), (183, 275)]

g.onKey(keyPressed)
g.onTimer(bothofthem, 10)
g.run()
Ejemplo n.º 9
0
def update_mouth():
    step = g.xCoord(mouth_help)
    global m
    m = 1 / (step + 2)
    g.brushColor('red')
    g.polygon([(600 / z, 500 / z + 150 / z),
               (600 / z + 150 * m / z, 500 / z + 60 / z),
               (600 / z - 150 * m / z, 500 / z + 60 / z),
               (600 / z, 500 / z + 150 / z)])
    step += 1
    if step >= 7:
        g.moveObjectBy(mouth_help, -7, 0)


g.onTimer(update_mouth)

# eyes
colors = ('green', 'blue', 'red', 'yellow', 'black', 'white', 'orange',
          'magenta')

g.brushColor('blue')
eye_1 = g.circle(525 / z, 430 / z, 60 / z)
eye_2 = g.circle(675 / z, 430 / z, 60 / z)
help_obj_eye_1 = g.rectangle(0, 0, 1, 1)
g.changeFillColor(help_obj_eye_1, 'green')


def update_eye_1():
    g.moveObjectBy(help_obj_eye_1, 1, 0)
    g.changeFillColor(eye_1, colors[g.xCoord(help_obj_eye_1)])
Ejemplo n.º 10
0
obj = polygon([(50 * k, 50 * k), (150 * k, 50 * k), (150 * k, 150 * k),
               (50 * k, 150 * k)])

# changeCoord(obj,[(x,y),(x,y)])
# Animation

i = 0


def update():
    global i
    global j
    global x1
    global y1
    global x2
    global y2
    i += 1
    if i >= 360:
        i = 0
    moveObjectBy(obj1, 13 * math.sin(i), 10 * math.cos(i))
    moveObjectBy(obj2, 7 * math.cos(i), 10 * math.sin(i))


# ##

deleteObject(obj)

onTimer(update, 100)

run()
Ejemplo n.º 11
0
                graph.moveObjectBy(a[10], 1, 0)
            else:
                graph.moveObjectBy(a[10], -5, 0)
        if num == 12:
            if graph.xCoord(a[12]) < 285:
                graph.moveObjectBy(a[12], 1, 0)
            else:
                graph.moveObjectBy(a[12], -5, 0)
        if num == 13:
            if graph.xCoord(a[13]) < 290:
                graph.moveObjectBy(a[13], 1, 0)
            else:
                graph.moveObjectBy(a[13], -5, 0)
        if num == 14:
            if graph.xCoord(a[14]) < 295:
                graph.moveObjectBy(a[14], 1, 0)
            else:
                graph.moveObjectBy(a[14], -5, 0)
        if num == 15:
            if graph.xCoord(a[15]) < 300:
                graph.moveObjectBy(a[15], 1, 0)
            else:
                graph.moveObjectBy(a[15], -5, 0)


graph.onTimer(movement, 100)

a = metal_constr_left(280, 340)

graph.run()
Ejemplo n.º 12
0
    x0 = width - width / 2 * 0.4
    y0 = height - height / 2 * 0.4
    xk = 0.4
    yk = 0.4

    def shrinkPoint(v, x0, y0, xk, yk):
        return [(v[0] - x0) * xk + x0, (v[1] - y0) * yk + y0]

    def shrinkPolygon(polygon, x0, y0, xk, yk):
        return {
            'color': polygon['color'],
            'points':
            [shrinkPoint(v, x0, y0, xk, yk) for v in polygon['points']]
        }

    polygons = []
    for i in range(0, 3):
        shrink = SIZE**(-(-tickId % SPEED + (i - 1) * SPEED) / SPEED)
        polygons += [
            shrinkPolygon(polygon, width / 2, height / 3, shrink, shrink)
            for polygon in scene[0]['polygons']
        ]

    updatePolygons()


gr.onTimer(drawLoop, 1000 // 30)

gr.run()
Ejemplo n.º 13
0
        graph.brushColor("#C87137")
        right_ear_dark = graph.polygon([(131, 616),
                                        (171, 633),
                                        (185 + counter,
                                         555)])
        graph.brushColor("#DEAA87")
        right_ear_light = graph.polygon([(139, 614),
                                         (168, 625),
                                         (178 + counter,
                                          570)])
        graph.brushColor("#C87137")
        left_ear_dark = graph.polygon([(50, 643),
                                       (84, 615),
                                       (21 - counter,
                                        565)])
        graph.brushColor("#DEAA87")
        left_ear_light = graph.polygon([(54, 634),
                                        (76, 613),
                                        (28 - counter,
                                         577)])

        counter -= 1
        if counter < -21:
            counter = 1


graph.onTimer(eyes_move, 10)
graph.onTimer(ears_move, 50)

graph.run()
    yozh.append(trg(435, 420, -20))
    yozh.append(trg(440, 425, -20))
    yozh.append(trg(445, 425, -20))
    yozh.append(trg(450, 420, -20))
    yozh.append(trg(455, 415, -20))
    yozh.append(trg(460, 410, -20))
    yozh.append(trg(460, 420, -20))
    yozh.append(trg(465, 415, -20))


X = 200
Y = 300
Size = 1.5
F = [-50]
t = [0]
yozh = []

graph.brushColor(150, 150, 150)
graph.rectangle(0, 350, 500, 600)
graph.brushColor(100, 200, 140)
graph.rectangle(0, 0, 500, 350)
graph.brushColor(250, 200, 0)
graph.rectangle(0, 0, 30, 380)
graph.rectangle(340, 0, 390, 385)
graph.rectangle(460, 0, 490, 420)
graph.rectangle(50, 0, 150, 600)

graph.onTimer(Esh, 50)

graph.run()