Ejemplo n.º 1
0
def draw():
    p5.background(0)

    if player.walking:
        settings.Maps[settings.currentMap].move(player)
        player.walkingAnimation(settings.Maps[settings.currentMap])
        if player.walkTimer % player.walkingAnimationTime == 0 and player.stopRequest:
            player.walking = False
            player.walkTimer = 0

    settings.Maps[settings.currentMap].show()
    player.show()
    settings.Maps[settings.currentMap].drawExtras()

    p5.stroke(255)
    p5.stroke_weight(1)
    if showGrid:
        for x in range(settings.Maps[settings.currentMap].gridWidth + 2):
            p5.line((settings.Maps[settings.currentMap].GridtoPosX(x),
                     settings.Maps[settings.currentMap].GridtoPosY(0)),
                    (settings.Maps[settings.currentMap].GridtoPosX(x),
                     settings.Maps[settings.currentMap].GridtoPosY(
                         settings.Maps[settings.currentMap].gridHeight + 1)))
        for y in range(settings.Maps[settings.currentMap].gridHeight + 2):
            p5.line((settings.Maps[settings.currentMap].GridtoPosX(0),
                     settings.Maps[settings.currentMap].GridtoPosY(y)),
                    (settings.Maps[settings.currentMap].GridtoPosX(
                        settings.Maps[settings.currentMap].gridWidth + 1),
                     settings.Maps[settings.currentMap].GridtoPosY(y)))
Ejemplo n.º 2
0
def draw():
    global fountains
    global gravity
    global wind
    global repeller

    background(120)

    if mouse_is_pressed:
        fountains.append(ParticleSystem(mouse_x, mouse_y, len(fountains)))
        print(f"there are {len(fountains)} fountains.")

    for fountain in reversed(fountains):

        if fountain.is_empty:
            print(f"fountain {fountain.identifier} empty")
            fountains.remove(fountain)
        fountain.update()
        fountain.apply_force(gravity)
        fountain.apply_repeller(repeller)
        repeller.display()
        if key_is_pressed:
            mouse = Vector(mouse_x, mouse_y)
            fountain.apply_force(wind.wind_force(mouse))
            wind.display(mouse)
Ejemplo n.º 3
0
def draw():

    global planet, moon

    p5.fill(255)
    if not moon.finished:
        p5.background(0)
        p5.scale(1, -1)
        p5.translate(0, -height)

        moon.collide(planet)

        moon.update(planet, G)

        #planet.update(moon,G)

        p5.no_fill()
        p5.stroke(255, 60)
        #p5.circle((planet.pos.x,planet.pos.y),2*abs(moon.relpos(planet)))

    p5.fill(10, 173, 73)
    p5.stroke(0)
    planet.show()

    p5.fill(0, 0, 255)
    p5.stroke(0, 0, 255)
    moon.show()
Ejemplo n.º 4
0
    def draw(self):
        if self.frame_rate == 0:
            p5.background(0, 0, 0)  # set initial background to black

        # action
        if self.paused:
            return

        self.frame_rate += 1

        self.update()

        # MARK: actual drawing
        p5.background(0, 0, 0, 90)

        p5.fill(255)
        p5.stroke(255)

        p5.rect((self.user.x, self.user.y), self.block_width,
                self.block_height)
        p5.rect((self.machine.x, self.machine.y), self.block_width,
                self.block_height)
        p5.ellipse((self.ball.x, self.ball.y), 2 * self.ball_radius,
                   2 * self.ball_radius)

        if self.draw_prediction and self.last_prediction is not None:
            p5.no_fill()
            p5.stroke(220, 0, 0)
            p5.ellipse((self.width - self.block_width - self.ball_radius,
                        self.last_prediction), 2 * self.ball_radius,
                       2 * self.ball_radius)
Ejemplo n.º 5
0
def draw():
    background(30, 30, 47)

    for boid in flock:
        boid.apply_behaviors(flock)
        boid.update()
        boid.show()
Ejemplo n.º 6
0
    def draw_objects(self):
        # global simulation

        # triangle((0, 0), (0, 200), (350, 100))
        background(30, 30, 47)

        # don't paint obstacles for free run
        if self.free_run:
            return

        fill(50)
        # shaded are upper quadrant
        quad((0, 0), (0, 160), (280, 256), (self.shaded_area_x, 0))
        quad((0, self.height), (0, 640), (280, 544),
             (self.shaded_area_x, self.height))

        fill(102)
        triangle((0, 160), (0, 640), (700, 400))

        # fishes' start box
        rect((self.box_left, 335), self.box_width, self.box_width)

        # replica line
        for rc in self.replicas_coordinates:
            line((0, rc[2]), (rc[0], rc[1]))
        # line((0, 720), (self.replica_x_start, self.replica_y_start))

        # shaded area line
        line((self.shaded_area_x, 0), (self.shaded_area_x, self.height))

        # 544

        # decision line
        line((self.decision_x, 0), (self.decision_x, self.height))
Ejemplo n.º 7
0
def setup():
    global point_a
    global point_b
    size(600, 360)
    background(255)
    point_a = Vector(100, 300)
    point_b = Vector(400, 100)
Ejemplo n.º 8
0
def draw():
    global Food
    p5.background(51)
    Snake.update()
    Snake.show()
    Food.show()
    Snake.eat(Food)
Ejemplo n.º 9
0
def draw():
    global ofset, x, y, z,fp,fl
    if(flag7=="fsek"):
        ofset = sek
    if (flag2 == "pus"):
        pass
    if(flag8=="nxt" or flag9=="pev"):
        ofset=sek
        fp=fl

    else:
        signal, sampling_rate = audio2numpy.audio_from_file(fp, offset=ofset, duration=dur, dtype='int')
        p.background(250)
        signal = abs(signal)
        # signal = signal[..., 1]
        ofset = ofset + dur
        # print(np.size(signal[:250]))
        for i in signal:
            p.line((x, height - 5), (x, -(200 * i[1] + 50) + height - 5))
            x +=1.5
            p.line((x, height - 5), (x, -(200 * i[0]+100) + height - 5))
            x+=1.5
            p.line((x, height - 5), (x, -(200*i[1]+50)+height - 5))
            x +=1.5
            if (ofset >= final):
                pass
        time.sleep(dur)
        x = 5
Ejemplo n.º 10
0
def draw():
    global Maps, showGrid
    p5.background(0)
    Maps[0].show()

    if showGrid:
        p5.stroke(255)
        p5.no_fill()
        for x in range(Maps[0].gridWidth+1):
            x += (width/2)/scl-Maps[0].gridpos.x-0.5
            for y in range(Maps[0].gridHeight+1):
                y += (height/2)/scl-Maps[0].gridpos.y-9/32
                p5.begin_shape()
                p5.vertex(x*scl, y*scl)
                p5.vertex(x*scl, (y+1)*scl)
                p5.vertex((x+1)*scl, (y+1)*scl)
                p5.vertex((x+1)*scl, y*scl)
                p5.end_shape()

    if player.walking:
        Maps[0].move(player)
        player.walkingAnimation(Maps[0])
        if player.walkTimer % player.walkingAnimationTime == 0 and player.stopRequest:
            player.walking = False
            player.walkTimer = 0

    p5.fill(255, 0, 0, 70)

    # p5.rect((4*scl+scl*((width/2)/scl-Maps[0].gridpos.x-0.5),4*scl+scl*((height/2)/scl-Maps[0].gridpos.y-9/32)),scl,scl)
    player.show()
    print(Maps[0].gridpos.x, Maps[0].gridpos.y)
Ejemplo n.º 11
0
def draw():
    pf.background(0)
    pf.rect_mode("CORNER")
    b = Bar(100, 50)
    # b.is_fill = False
    b.str = "Hello,老番茄"
    b.disp()
Ejemplo n.º 12
0
def draw():
    p.background(0)
    p.translate(20, 20)
    for x in range(30):
        for y in range(30):
            d = p.dist((30*x, 30*y), (mouse_x, mouse_y))
            p.fill(0.5*d, 255, 255)
            p.rect((30*x, 30*y), 25, 25)
Ejemplo n.º 13
0
def setup():
    size(640, 360)
    no_stroke()
    background(0)
    global perlx
    global perly
    perlx = random_uniform(1000)
    perly = 0
Ejemplo n.º 14
0
def draw():
    global flock
    background('black') #coloring the map
    for boid in flock: 
        boid.edges() 
        boid.apply_behaviour(flock) 
        boid.update()
        boid.show()
Ejemplo n.º 15
0
def draw():
    global ball
    p5.background(0)
    ball.followMouse()
    ball.show()
    for i in range(len(Lines)):
        Lines[i].show()
        ball.drawProjectionLine(Lines[i])
Ejemplo n.º 16
0
def draw():
    # Arka planı siyah yap
    p5.background(0)
    # Orijini pencerenin merkezine taşı
    p5.translate(width / 2, height / 2)

    # clock fonsiyonundan gelen değerleri
    # sırasıyla h, m ve s değişkenlerine ata
    h, m, s = clock()

    # Çevre çizgisi çizme
    p5.no_stroke()

    # [0, 360) aralığında 6'şar derece aralıklarla değer oluştur
    # 0, 6, 12, ...,  342, 348, 354
    for i in range(0, 360, 6):

        # Kutupsal koordinat sisteminde
        # (r_d, i) değerini kartezyen koordinat sistemine dönüştür
        d_x, d_y = pol2car(r_d, i)

        # i değeri 30'un tam katıysa,
        if i % 30 == 0:
            # saat değerleri için nokta koyacağız
            p5.fill(255, 0, 0)
            r = 15
        else:
            # dakika/saniye değerleri için nokta koyacağız
            p5.fill(255)
            r = 10

        # Belirlenen özelliklerle hesaplanan noktada
        # bir daire çiz
        p5.circle((d_x, d_y), r)

    # Akrep kolunun ucunun konumunu hesala
    h_x, h_y = pol2car(r_h, h)
    # Akrep kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(5)
    # Akrep konu çiz
    p5.line((0, 0), (h_x, h_y))

    # Yelkovan kolunun ucunun konumunu hesala
    m_x, m_y = pol2car(r_m, m)
    # Yelkovan kolunun şekil ayarlarını yap
    p5.stroke(255)
    p5.stroke_weight(3)
    # Yelkovan konu çiz
    p5.line((0, 0), (m_x, m_y))

    # Saniye kolunun ucunun konumunu hesala
    s_x, s_y = pol2car(r_s, s)
    # Saniye kolunun şekil ayarlarını yap
    p5.stroke(255, 0, 0)
    p5.stroke_weight(1)
    # Saniye konu çiz
    p5.line((0, 0), (s_x, s_y))
Ejemplo n.º 17
0
def new_doodle(d):
    p5.background(240, 238, 225)

    n = doodles[d]

    query = "SELECT MIN(vertex_x) as 'left', " \
          "MAX(vertex_x) as 'right', " \
                   "MIN(vertex_y) as 'top', " \
                   "MAX(vertex_y) as 'bottom' " \
            "FROM path_verticies " \
            "WHERE doodle_id = '%s'" % d

    table_rows = db.query(query)
    outers = {
        k: v
        for k, v in zip(['left', 'right', 'top', 'bottom'], table_rows[0])
    }
    l, r, t, b = outers['left'], outers['right'], outers['top'], outers[
        'bottom']

    x_interp = interp1d([l, r], [0, res])
    y_interp = interp1d([t, b], [0, res])

    for i in range(n):

        path_chars_columns = [
            'doodle_id', 'path_number', 'color_r', 'color_g', 'color_b',
            'stroke_weight'
        ]

        path_verts_columns = [
            'doodle_id', 'path_number', 'vertex_number', 'vertex_x', 'vertex_y'
        ]

        query = "SELECT * FROM path_characteristics " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        table_rows = db.query(query)
        path_chars = {k: v for k, v in zip(path_chars_columns, table_rows[0])}

        query = "SELECT * FROM path_verticies " \
                "WHERE doodle_id = '%s' AND path_number = %d" % (d, i)
        table_rows = db.query(query)
        path_verts = pd.DataFrame(table_rows, columns=path_verts_columns)

        p5.stroke(path_chars['color_r'], path_chars['color_g'],
                  path_chars['color_b'])

        for i in range(path_verts.shape[0] - 1):

            row = path_verts.iloc[i]
            row_next = path_verts.iloc[i + 1]

            x = round(float(x_interp(row.vertex_x)), 2)
            y = round(float(y_interp(row.vertex_y)), 2)
            x_next = round(float(x_interp(row_next.vertex_x)), 2)
            y_next = round(float(y_interp(row_next.vertex_y)), 2)

            p5.line((x, y), (x_next, y_next))
Ejemplo n.º 18
0
def draw():
    global t
    p.background(255)
    p.translate(width/2, height/2)
    p.rotate(p.radians(t))
    for _ in range(12):
        p.rect((200, 0),50, 50)
        p.rotate(p.radians(360/12))
    t += 2
Ejemplo n.º 19
0
def draw():
    background(30, 30, 47)
    for boid in boid_list:
        nearby_boids = boid.find_nearby_boids()
        boid.show(nearby_boids)
        boid.allignment(nearby_boids)
        boid.cohesion(nearby_boids)
        boid.seperation(nearby_boids)
        boid.move()
Ejemplo n.º 20
0
def draw():
    #everytime call event
    background(30, 30, 47)

    for boid in flock:
        boid.show()
        boid.behavir_commit(flock)
        boid.update()
        boid.edges()
Ejemplo n.º 21
0
def draw():
    global counter
    counter+=0.01
    p5.background(0)
    p5.fill(0,255,0)
    p5.stroke(0)
    #p5.rotate_x(counter)
    p5.rotate_y(counter)
    #p5.sphere(300)
    p5.box(300,300,300)
Ejemplo n.º 22
0
def draw():
  p5.background(238)

  p5.normalMaterial()
  p5.push()
  p5.rotateZ(p5.frameCount * 0.01)
  p5.rotateX(p5.frameCount * 0.01)
  p5.rotateY(p5.frameCount * 0.01)
  p5.torus(120, 40)
  p5.pop()
Ejemplo n.º 23
0
def draw():
    # update the grid - done every time
    background(30, 30, 47)

    for boid in flock:
        boid.show()
        boid.align_to_neighbors(flock)
        boid.maintain_group_cohesion(flock)
        boid.maintain_group_seperation(flock)
        boid.update_position()
Ejemplo n.º 24
0
def draw():
    global fountain
    global field
    background(0)

    fountain.run(field)
    field.alter_vectors()

    if key_is_pressed:
        field.display()
Ejemplo n.º 25
0
def draw():
    global vehicles
    background(0)
    vehicles.update()

    if mouse_is_pressed:
        vehicles.add_one()

    if key_is_pressed:
        vehicles.sub_one()
Ejemplo n.º 26
0
def draw():
    global smallBall, bigBall
    p5.background(0)
    smallBall.updatePos(bigBall)
    smallBall.collision(bigBall)

    smallBall.show()
    bigBall.show()
    p5.stroke(255, 0, 0)
    p5.line((smallBall.pos), (bigBall.pos))
Ejemplo n.º 27
0
def draw():
    global flock

    background(30, 30, 47)

    for boid in flock:
        boid.edges()
        boid.apply_behaviour(flock)
        boid.update()
        boid.show()
Ejemplo n.º 28
0
def draw():
    p.background(255)
    p.translate(width / 2, height / 2)
    grid(xscl, yscl)
    ang = p.remap(mouse_y, (0, width), (0, p.TWO_PI))
    rot_matrix = [[p.cos(ang), -p.sin(ang)], [p.sin(ang), p.cos(ang)]]
    newmatrix = transpose(multmatrix(rot_matrix, transpose(fmatrix)))
    graphPoints(fmatrix)
    p.stroke(255, 0, 0)
    graphPoints(newmatrix)
Ejemplo n.º 29
0
def draw():
    global smallBall, bigBall
    p5.background(0)
    MousePos = p5.Vector(mouse_x, mouse_y)
    smallBall.pos = MousePos
    smallBall.collision(bigBall)
    print(abs(smallBall.relativePos(bigBall)))
    smallBall.show()
    bigBall.show()
    p5.stroke(255, 0, 0)
    p5.line((smallBall.pos), (bigBall.pos))
Ejemplo n.º 30
0
def draw():
    p5.background(0)
    pos = p5.Vector(200, 200)
    mouse = p5.Vector(mouse_x, mouse_y)
    v = mouse - pos
    #m=abs(v)
    v = v.normalize() * 100
    p5.translate(width / 2, height / 2)
    p5.stroke_weight(4)
    p5.stroke(255)
    p5.line((0, 0), (v.x, v.y))