Example #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)))
Example #2
0
def grid(xscl, yscl):
    p.stroke_weight(1)
    p.stroke(0, 255, 255)
    for i in range(xmin, xmax + 1):
        p.line((i * xscl, ymin * yscl), (i * xscl, ymax * yscl))
    for i in range(ymin, ymax + 1):
        p.line((xmin * xscl, i * yscl), (xmax * xscl, i * yscl))
    p.stroke(0)
    p.line((0, ymin * yscl), (0, ymax * yscl))
    p.line((xmin * xscl, 0), (xmax * xscl, 0))
Example #3
0
def draw():

    p5.translate(width / 2, height / 2)

    #v=p5.Vector(randint(-100,100),randint(-100,100))
    v = p5.Vector.random_2D()  #random unit vector in 2d
    v *= 100
    p5.stroke_weight(4)
    p5.stroke(255, 50)
    p5.line((0, 0), (v.x, v.y))
Example #4
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))
Example #5
0
def draw():
    global xscl, yscl
    p.background(255)
    p.translate(width / 2, height / 2)
    grid(xscl, yscl)
    p.stroke_weight(2)
    p.stroke(0)
    newmatrix = transpose(multmatrix(transformation_matrix,
                                     transpose(fmatrix)))
    graphPoints(fmatrix)
    p.stroke(255, 0, 0)
    graphPoints(newmatrix)
Example #6
0
def setup():
    # isimler adlı değikeni düzenleyebilmek için global
    global isimler

    # Pencere boyutu ayarla
    p5.size(1920, 1080)
    # isimler listesini al
    isimler = isimleri_al()

    # çizgi rengi belirle
    p5.stroke(p5.Color(41, 255, 41, 41))
    # çizgi kalınlığı belirle
    p5.stroke_weight(3)
Example #7
0
def draw():
    p.background(255)
    p.translate(width/2, height/2)
    points = []
    t = 0
    while t < 1000:
        points.append(harmonograph(t))
        t += 0.01
    for i, s in enumerate(points):
        p.stroke_weight(0.01)
        p.stroke(255, 0, 0)
        if i < len(points)-1:
            p.line((s[0], s[1]), (points[i+1][0], points[i+1][1]))
Example #8
0
def draw():
    p5.background(0)
    p5.stroke(255)
    p5.stroke_weight(strokeWeight)
    if showGrid:
        for x in range(int(gridW / gridScl) + 1):
            x += gridOffsetX / gridScl
            p5.line((x * gridScl, gridOffsetY),
                    (x * gridScl, gridOffsetY + gridH))

        for y in range(int(gridH / gridScl) + 1):
            y += gridOffsetY / gridScl
            p5.line((gridOffsetX, y * gridScl),
                    (gridOffsetX + gridW, y * gridScl))
Example #9
0
def draw():
    p.background(0)
    p.translate(width / 2, height / 2)
    # grid(xscl, yscl)

    rot = p.remap(mouse_x, (0, width), (0, p.TWO_PI))
    tilt = p.remap(mouse_y, (0, height), (0, p.TWO_PI))
    rot_matrix = rottilt(rot, tilt)

    newmatrix = multmatrix(fmatrix, rot_matrix)

    p.no_fill()
    p.stroke_weight(2)
    p.stroke(255, 0, 0)
    graphPoints2(newmatrix, edges)
 def draw(self):
     p5.stroke_weight(0.01)
     if self.stage > 0:
         p5.rect((self.bottomLeft.x, self.bottomLeft.y), self.linewidth,
                 -self.height)
     if self.stage > 1:
         p5.rect((self.bottomLeft.x, self.bottomLeft.y - self.height),
                 self.width / 2 + self.linewidth / 2, self.linewidth)
     if self.stage > 2:
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 2,
                  self.bottomLeft.y - self.height), self.linewidth,
                 self.height / 4)
     if self.stage > 3:
         p5.no_fill()
         p5.circle((self.bottomLeft.x + self.width / 2, self.bottomLeft.y -
                    self.height + self.height / 4 + (self.linewidth * 2.5)),
                   self.linewidth * 5,
                   mode="CENTER")
     if self.stage > 4:
         p5.fill(255)
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5)), self.linewidth / 2,
                 self.height / 4)
     if self.stage > 5:
         p5.rect((self.bottomLeft.x + self.width / 2 - self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + 10), -self.width / 4,
                 self.linewidth / 2)
     if self.stage > 6:
         p5.rect((self.bottomLeft.x + self.width / 2 + self.linewidth / 4,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + 10), self.width / 4,
                 self.linewidth / 2)
     if self.stage > 7:
         p5.stroke(255)
         p5.stroke_weight(4)
         p5.line((self.bottomLeft.x + self.width / 2,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + self.height / 4),
                 (self.bottomLeft.x + self.width - self.width / 4,
                  self.bottomLeft.y - self.height / 12))
     if self.stage > 8:
         p5.line((self.bottomLeft.x + self.width / 2,
                  self.bottomLeft.y - self.height + self.height / 4 +
                  (self.linewidth * 5) + self.height / 4),
                 (self.bottomLeft.x + self.width - self.width * 3 / 4,
                  self.bottomLeft.y - self.height / 12))
Example #11
0
 def rect(self):
     if self.is_rect:
         with pf.push_style():
             if not self.is_stroke and not self.is_fill:
                 return
             pf.color_mode("RGB")
             if self.is_fill:
                 pf.fill(*self.fill_rgb)
             else:
                 pf.no_fill()
             if self.is_stroke:
                 pf.stroke_weight(self.stroke_weight)
                 pf.stroke(*self.stroke_rgb)
             else:
                 pf.no_stroke()
             pf.rect([self.get_rect_x(), self.get_rect_y()], self.w, self.h)
Example #12
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))
Example #13
0
    def draw(self, stroke, stroke_weight):
        colors = [
            (180, 180, 180),
            (255, 255, 255),
            (50, 50, 125),
            (255, 255, 0),
            (0, 255, 255),
            (0, 100, 255),
            (100, 255, 100)
        ]

        with p5.push_matrix():
            p5.apply_matrix(self.surface.get_transform_mat())

            with p5.push_style():
                try:
                    for y, row in enumerate(self.grid):
                        for x, cell in enumerate(row):
                            p5.stroke(stroke)
                            p5.stroke_weight(stroke_weight * (4 if cell.selected else 1))
                            p5.fill(p5.Color(*colors[cell.id]) if cell.id > -1 else p5.Color(0, 0, 0, 0))
                            p5.rect(x, y, 1, 1)
                except TypeError:
                    pass
Example #14
0
def draw():
    # pf.image_mode("center")
    # pf.tint()
    # img_size[0]-=1
    pf.background(255)
    # pf.image(img0,(100,100))
    pf.text_font(font)

    # pf.stroke_weight(0)
    pf.text_align("center", "center")
    # pf.stroke(255,0,0)
    # pf.no_fill()

    pf.text_size(100)

    en_str = "hello 你好"

    pf.fill(255, 0, 0)

    gap = 100
    height = 20
    pf.text(en_str, (50, height))

    pf.stroke(0, 0, 255)
    pf.stroke_weight(5)

    height += gap
    pf.text(en_str, (50, height))

    pf.stroke_weight(-5)
    height += gap
    pf.text(en_str, (50, height))

    pf.no_fill()
    height += gap
    pf.stroke_weight(5)
    pf.text(en_str, (50, height))

    height += gap
    pf.stroke_weight(-5)
    pf.text(en_str, (50, height))
Example #15
0
 def show(self):
     p5.stroke(255)
     p5.stroke_weight(2)
     p5.fill(255, 100)
     p5.circle((self.pos.x, self.pos.y), 32)
def draw():
    global Man, wordDisplay, newLetter, Game
    p5.background(0)
    p5.fill(255)
    p5.stroke(255)
    p5.stroke_weight(1)
    if not Man.GameWon and not Man.GameOver:
        wordDisplay.displayWord(Game.revealed)
    p5.fill(255)
    p5.stroke(255)
    Man.draw()
    if not Man.GameWon and not Man.GameOver:
        if key_is_pressed:
            if key not in [
                    "ENTER", "SHIFT", "BACKSPACE", "UNKNOWN", "tab", "UP",
                    "DOWN", "LEFT", "RIGHT"
            ]:
                newLetter = str(key).lower()
            elif key == "BACKSPACE":
                newLetter = ""
            elif key == "ENTER":
                if len(newLetter
                       ) != 0 and newLetter not in Game.guessedLetters:
                    Game.enterLetter(newLetter, Man)
                    newLetter = ""

    if len(newLetter) != 0:
        txt_size = 40
        EnteredLetterFont = p5.create_font("arial.ttf", txt_size)
        p5.text_font(EnteredLetterFont, txt_size)
        p5.text_align("CENTER", "CENTER")
        p5.text(newLetter, (width / 2, height * 3 / 4 - 20))

    guessedLettersstring = ""
    for i in range(len(Game.guessedLetters)):
        guessedLettersstring += Game.guessedLetters[i]
        guessedLettersstring += " "

    guessedLetterFont = p5.create_font("arial.ttf", 20)
    p5.text_font(guessedLetterFont, 20)

    p5.text_align("CENTER", "CENTER")
    p5.text(("Already used Letters:"), (width / 2, height * 7 / 8))
    p5.text(str(guessedLettersstring), (width / 2, (height * 7 / 8) + 25))

    Man.checkIfGameOver(Game)

    if Man.GameWon:
        txt_size = 30
        #txt_size=int((width/7)*4/3)
        GameWonFont = p5.create_font("arial.ttf", txt_size)
        p5.text_font(GameWonFont, txt_size)
        p5.text_align("CENTER", "CENTER")
        p5.text("YOU WON", (width / 2, height / 2))
        p5.text("The Right word was:", (width / 2, height / 2 + 30))
        p5.text("{}".format(word), (width / 2, height / 2 + 60))
        newLetter = ""
    if Man.GameOver:
        txt_size = 30
        #txt_size=int((width/9)*4/3)
        GameOverFont = p5.create_font("arial.ttf", txt_size)
        p5.text_font(GameOverFont, txt_size)
        p5.text_align("CENTER", "CENTER")
        p5.text("YOU LOST", (width / 2, height / 2))
        p5.text("The Right word was:", (width / 2, height / 2 + 30))
        p5.text("{}".format(word), (width / 2, height / 2 + 60))
        newLetter = ""