Exemple #1
0
def setup():
    ratio = 1.8
    pf.size(1280 / ratio, 720 / ratio)
    pf.text_font(font)
    pf.text_size(50)
    pf.no_stroke()
    pf.no_loop()
Exemple #2
0
 def display(self):
     """
     Display the letter on the window.
     """
     fill(DEFAULT_SENTENCE_COLOR)
     text_align(DEFAULT_SENTENCE_ALIGNMENT)
     text_font(self.font)
     text(self.character, (self.x, self.y))
Exemple #3
0
def setup():
    global img_L, t1
    ratio = 1.2
    pf.size(win_w / ratio, win_h / ratio)
    pf.text_font(font)
    # pf.no_stroke()
    # pf.no_loop()
    t1 = time.time()
    pr.enable()
Exemple #4
0
def create_sentence(characters, fonts):
    """
    Create a sentence.
    :param characters: the characters composing the sentence.
    :param fonts: the fonst used to write the sentence.
    :return: the sentence.
    """
    position_x = DEFAULT_FONT_SIZE
    letters = []
    for character in characters:
        font = choice(fonts)
        letters.append(Letter(position_x, DEFAULT_FONT_SIZE, character, font))
        text_font(font)
        position_x += text_width(character)
    return Sentence(letters)
    def displayWord(self, word):
        self.word = word
        self.wordLength = len(word)
        self.spacing = (self.width / (self.wordLength)) / 2

        self.offset = (width / 2 - self.width / 2) + self.spacing / 2

        self.txt_size = int(self.spacing * 4 / 3)
        self.GuessFont = p5.create_font("arial.ttf", self.txt_size)
        p5.text_font(self.GuessFont, self.txt_size)
        p5.text_align("CENTER", "BASELINE")
        self.txt_width = p5.text_width("A")

        for i in range(self.wordLength):
            p5.fill(255)
            p5.text(word[i],
                    ((i * 2 * self.spacing) + self.spacing / 2 + self.offset,
                     self.y - (self.txt_width * 4 / 3) - 2))
            p5.line((i * 2 * self.spacing + self.offset, self.y),
                    (((i * 2) + 1) * self.spacing + self.offset, self.y))
Exemple #6
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))
Exemple #7
0
def setup():
    ratio = 1.8
    pf.size(1280/ratio,720/ratio)
    pf.text_font(font)
    pf.title("Patato")
    pf.no_loop()
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 = ""