Ejemplo n.º 1
0
    def test_bubble(self):
        """
        Check that the SpeechBubble renderer works.
        """
        # Standard rendering.
        renderer = SpeechBubble("hello")
        self.assertEqual(str(renderer),
                         ".-------.\n" + "| hello |\n" + "`-------`\n")

        # Left bubble.
        renderer = SpeechBubble("world", tail="L")
        self.assertEqual(
            str(renderer), ".-------.\n" + "| world |\n" + "`-------`\n" +
            "  )/  \n" + "-\"`\n")

        # Right bubble
        renderer = SpeechBubble("bye!", tail="R")
        self.assertEqual(
            str(renderer), ".------.\n" + "| bye! |\n" + "`------`\n" +
            "    \\(  \n" + "     `\"-\n")

        # Unicode rendering.
        renderer = SpeechBubble("hello", uni=True)
        self.assertEqual(str(renderer), u"╭───────╮\n"
                         u"│ hello │\n"
                         u"╰───────╯\n")
Ejemplo n.º 2
0
 def _create_instructions_effect(self):
     x = int(self._screen.width *
             (config.instructions['position']['x'] / 100))
     y = int(self._screen.height *
             (config.instructions['position']['y'] / 100))
     return Print(self._screen,
                  SpeechBubble(config.instructions['text'], uni=True), y, x)
Ejemplo n.º 3
0
def demo(screen):
    scenes = []

    for bg, name in [
            (Screen.COLOUR_RED, "RED"),
            (Screen.COLOUR_YELLOW, "YELLOW"),
            (Screen.COLOUR_GREEN, "GREEN"),
            (Screen.COLOUR_CYAN, "CYAN"),
            (Screen.COLOUR_BLUE, "BLUE"),
            (Screen.COLOUR_MAGENTA, "MAGENTA"),
            (Screen.COLOUR_WHITE, "WHITE")]:
        effects = [
            Wipe(screen, bg=bg, stop_frame=screen.height * 2 + 30),
            Print(screen, FigletText(name, "epic"), screen.height // 2 - 4,
                  colour=7 - bg,
                  bg=bg,
                  start_frame=screen.height * 2),
            Print(screen,
                  SpeechBubble("Testing background colours - press X to exit"),
                  screen.height-5,
                  speed=1, transparent=False)
        ]
        scenes.append(Scene(effects, 0, clear=False))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 4
0
        def internal_checks(screen):
            # Create a base renderer
            plain_text = (".-------.\n" +
                          "| hello |\n" +
                          "`-------`\n")
            renderer = SpeechBubble("hello")
            self.assertEqual(str(renderer), plain_text)

            # Pretend that we always have an 8 colour palette for the test.
            screen.colours = 8

            # Check that the Rainbow renderer doesn't change this.
            rainbow = Rainbow(screen, renderer)
            self.assertEqual(str(rainbow), plain_text)

            # Check rainbow colour scheme.
            self.assertEqual(
                rainbow.rendered_text[1], [
                    [(1, 1, None), (1, 1, None), (3, 1, None), (3, 1, None), (2, 1, None),
                     (2, 1, None), (6, 1, None), (6, 1, None), (4, 1, None)],
                    [(1, 1, None), (3, 1, None), (3, 1, None), (2, 1, None), (2, 1, None),
                     (6, 1, None), (6, 1, None), (4, 1, None), (4, 1, None)],
                    [(3, 1, None), (3, 1, None), (2, 1, None), (2, 1, None), (6, 1, None),
                     (6, 1, None), (4, 1, None), (4, 1, None), (5, 1, None)],
                    []])
Ejemplo n.º 5
0
def _reset(screen):
    reset = Print(
        screen,
        SpeechBubble("Press 'r' to restart."),
        int(screen.height / 2),
        attr=Screen.A_BOLD,
    )
    return [reset]
Ejemplo n.º 6
0
    def test_bubble(self):
        """
        Check that the SpeechBubble renderer works.
        """
        renderer = SpeechBubble("hello")
        self.assertEqual(str(renderer),
                         ".-------.\n" + "| hello |\n" + "`-------`\n")

        renderer = SpeechBubble("world", tail="L")
        self.assertEqual(
            str(renderer), ".-------.\n" + "| world |\n" + "`-------`\n" +
            "  )/  \n" + "-\"`\n")

        renderer = SpeechBubble("bye!", tail="R")
        self.assertEqual(
            str(renderer), ".------.\n" + "| bye! |\n" + "`------`\n" +
            "    \\(  \n" + "     `\"-\n")
Ejemplo n.º 7
0
def _reset(screen):
    reset = Print(
        screen,
        SpeechBubble("Press 'r' to restart."),
        int(screen.height / 2) - 2,
        attr=ATTRS["bold"],
    )
    return [reset]
def _speak(screen, text, pos, start):
    return Print(screen,
                 SpeechBubble(text, "L", uni=screen.unicode_aware),
                 x=pos[0] + 4,
                 y=pos[1] - 4,
                 colour=Screen.COLOUR_CYAN,
                 clear=True,
                 start_frame=start,
                 stop_frame=start + TIC_SPEAK)
Ejemplo n.º 9
0
def _speak(screen, text, pos, start):
    return Print(screen,
                 SpeechBubble(text, "L"),
                 x=pos[0] + 4,
                 y=pos[1] - 4,
                 colour=Screen.COLOUR_CYAN,
                 clear=True,
                 start_frame=start,
                 stop_frame=start + 50)
Ejemplo n.º 10
0
    def whack(self, sound):
        global arrow

        x, y = self._path.next_pos()
        if self.overlaps(arrow, use_new_pos=True):
            arrow.say("OUCH!")
        else:
            self._scene.add_effect(Print(
                self._screen,
                SpeechBubble(sound), y, x, clear=True, delete_count=50))
Ejemplo n.º 11
0
 def __init__(self, screen, scene, path, text, **kwargs):
     """
     See :py:obj:`.Sprite` for details.
     """
     super(Speak, self).__init__(
         screen,
         renderer_dict={"default": SpeechBubble(text, "L")},
         path=TrackingPath(scene, path),
         colour=Screen.COLOUR_CYAN,
         **kwargs)
Ejemplo n.º 12
0
def display(screen):
    effects = [
        Cycle(screen, FigletText("Shanghai University", font='big'),
              screen.height // 2 - 10),
        Cycle(screen, FigletText("Edu-System", font='big'),
              screen.height // 2 - 1),
        Stars(screen, (screen.width + screen.height) // 2),
        Print(screen,
              SpeechBubble("Press 'space' to login."),
              screen.height // 2 + 10,
              attr=Screen.A_BOLD)
    ]
    screen.play([Scene(effects, 500)], repeat=False)
def fireworks(screen):
    scenes = []
    effects = [
        Stars(screen, screen.width),
        Print(screen,
              SpeechBubble("Press space to see it again"),
              y=screen.height - 3,
              start_frame=300)
    ]
    for _ in range(20):
        fireworks = [
            (PalmFirework, 25, 30),
            (PalmFirework, 25, 30),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (RingFirework, 20, 30),
            (SerpentFirework, 30, 35),
        ]
        firework, start, stop = choice(fireworks)
        effects.insert(
            1,
            firework(screen,
                     randint(0, screen.width),
                     randint(screen.height // 8, screen.height * 3 // 4),
                     randint(start, stop),
                     start_frame=randint(0, 250)))

    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("CONGRATULATIONS")),
              screen.height // 2 - 6,
              speed=1,
              start_frame=100))
    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("TO YOUR")),
              screen.height // 2 + 1,
              speed=1,
              start_frame=100))
    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("OPTIMAL SCHEDULE")),
              screen.height // 2 + 1,
              speed=1,
              start_frame=100))
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True, repeat=False)
Ejemplo n.º 14
0
def demo(screen, scene):
    with AsciinemaPlayer("test.rec", max_delay=0.1) as player, \
            AnsiArtPlayer("fruit.ans") as player2:
        screen.play([
            Scene([
                Print(screen, player, 0, speed=1, transparent=False),
                Print(screen,
                      SpeechBubble("Press space to see ansi art"),
                      y=screen.height - 3,
                      speed=0,
                      transparent=False)
            ], -1),
            Scene([
                Print(screen, player2, 0, speed=1, transparent=False),
                Print(screen,
                      SpeechBubble("Press space to see asciinema"),
                      y=screen.height - 3,
                      speed=0,
                      transparent=False)
            ], -1)
        ],
                    stop_on_resize=True,
                    start_scene=scene,
                    allow_int=True)
Ejemplo n.º 15
0
    def credits(self):
        scenes = []
        effects = [
            Print(self.screen,
                  SpeechBubble("Exiting GUI"),
                  self.screen.height // 2 - 1,
                  attr=Screen.A_BOLD)
        ]
        scenes.append(Scene(
            effects,
            duration=10,
            name="Exit",
        ))

        return scenes
Ejemplo n.º 16
0
def _speak(screen, text, pos, start, tail="L"):
    if tail == 'L':
        x = pos[0]
        y = pos[1] - 4
    else:
        x = pos[0] - len(text) - 4  # extra -4 for the boundaries
        y = pos[1] - 4
    return Print(screen,
                 SpeechBubble(text, tail, uni=screen.unicode_aware),
                 x=x,
                 y=y,
                 colour=Screen.COLOUR_CYAN,
                 clear=True,
                 start_frame=start,
                 stop_frame=start + 200)
Ejemplo n.º 17
0
def demo(screen):
    scenes = []

    effects = [
        Wipe(screen, bg=Screen.COLOUR_RED, stop_frame=screen.height * 2 + 30),
        Print(screen, FigletText("WOLOOLO", "epic"), screen.height // 2 - 4,
              colour=7 - Screen.COLOUR_RED,
              bg=Screen.COLOUR_RED,
              start_frame=screen.height * 2),
        Print(screen,
              SpeechBubble("Testing background colours - press X to exit"),
              screen.height-5,
              speed=1, transparent=False)
    ]
    scenes.append(Scene(effects, 0, clear=False))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 18
0
    def test_bubble(self):
        """
        Check that the SpeechBubble renderer works.
        """
        # Standard rendering.
        renderer = SpeechBubble("hello")
        self.assertEqual(str(renderer),
                         ".-------.\n" +
                         "| hello |\n" +
                         "`-------`")

        # Left bubble.
        renderer = SpeechBubble("world", tail="L")
        self.assertEqual(str(renderer),
                         ".-------.\n" +
                         "| world |\n" +
                         "`-------`\n" +
                         "  )/  \n" +
                         "-\"`\n")

        # Right bubble
        renderer = SpeechBubble("bye!", tail="R")
        self.assertEqual(str(renderer),
                         ".------.\n" +
                         "| bye! |\n" +
                         "`------`\n" +
                         "    \\(  \n" +
                         "     `\"-\n")

        # Unicode rendering.
        renderer = SpeechBubble("hello", uni=True)
        self.assertEqual(str(renderer),
                         u"╭───────╮\n"
                         u"│ hello │\n"
                         u"╰───────╯")

        # Multiline text rendering
        text = "Hello\n" \
               "World! \n" \
               "Hello World!"

        renderer = SpeechBubble(text, uni=True)
        self.assertEqual(str(renderer),
                         "╭──────────────╮\n" +
                         "│ Hello        │\n" +
                         "│ World!       │\n" +
                         "│ Hello World! │\n" +
                         "╰──────────────╯")

        # Test render height
        renderer = SpeechBubble("Hello World", uni=True)
        self.assertEqual(renderer.max_height, 3)
Ejemplo n.º 19
0
def fireworks(screen):
    scenes = []
    # Leer xlsx y seleccionar un estudiante
    student = get_student_from_xlsx(generation)
    student_split = student.split()
    effects = [
        Stars(screen, screen.width),
        Print(screen,
              SpeechBubble("Pulsa espacio para volver a ver"),
              y=screen.height - 3,
              start_frame=300)
    ]
    for _ in range(20):
        fireworks = [
            (PalmFirework, 25, 30),
            (PalmFirework, 25, 30),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (RingFirework, 20, 30),
            (SerpentFirework, 30, 35),
        ]
        firework, start, stop = choice(fireworks)
        effects.insert(
            1,
            firework(screen,
                     randint(0, screen.width),
                     randint(screen.height // 8, screen.height * 3 // 4),
                     randint(start, stop),
                     start_frame=randint(0, 250)))

    effects.append(Print(screen,
                         Rainbow(screen, FigletText("{} {}".format(student_split[0], student_split[1]), font='big')),
                         screen.height // 2 - 6,
                         speed=1,
                         start_frame=100))
    effects.append(Print(screen,
                         Rainbow(screen, FigletText("{} {}".format(student_split[2], student_split[3]), font='big')),
                         screen.height // 2 + 1,
                         speed=1,
                         start_frame=100))
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 20
0
def demo(screen):
    scenes = []
    effects = [
        Stars(screen, screen.width),
        Print(screen,
              SpeechBubble("Press space to see it again"),
              y=screen.height - 3,
              start_frame=300)
    ]
    for i in range(20):
        fireworks = [
            (PalmFirework, 25, 30),
            (PalmFirework, 25, 30),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (StarFirework, 25, 35),
            (RingFirework, 20, 30),
            (SerpentFirework, 30, 35),
        ]
        firework, start, stop = choice(fireworks)
        effects.insert(
            1,
            firework(screen,
                     randint(0, screen.width),
                     randint(screen.height // 8, screen.height * 3 // 4),
                     randint(start, stop),
                     start_frame=randint(0, 250)))

    effects.append(Print(screen,
                         Rainbow(screen, FigletText("HAPPY")),
                         screen.height // 2 - 6,
                         speed=1,
                         start_frame=100))
    effects.append(Print(screen,
                         Rainbow(screen, FigletText("NEW YEAR!")),
                         screen.height // 2 + 1,
                         speed=1,
                         start_frame=100))
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 21
0
 def intro_screen(self, screen):
     scenes = []
     effects = [
         Scroll(screen, 3),
         Mirage(screen, FigletText("A long time ago...", font='starwars'),
                screen.height, Screen.COLOUR_YELLOW),
         Mirage(screen,
                FigletText("In a yard far, far away", font='starwars'),
                screen.height + 8, Screen.COLOUR_YELLOW),
     ]
     scenes.append(Scene(effects, (screen.height + 104) * 3))
     effects = [
         Scroll(screen, 3),
         Print(screen, SpeechBubble("Press X to continue"),
               screen.height + 12, Screen.COLOUR_CYAN)
     ]
     scenes.append(Scene(effects, 300, clear=True))
     screen.play(
         scenes,
         stop_on_resize=True,
     )
def demo(screen):
    scenes = []
    effects = [
        Rain(
            screen,
            99**99,
        ),
        Print(screen,
              FigletText("Pr()j3ct 1/\/FIn1t3",
                         font='banner3' if screen.width > 80 else 'banner'),
              screen.height // 2 - 3,
              colour=2,
              bg=2),
        Print(screen,
              SpeechBubble("Pr3ss Q to St@rt"),
              screen.height - 5,
              speed=1,
              transparent=False)
    ]
    scenes.append(Scene(effects))
    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 23
0
def demo(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)
    podium = (8, 5)

    # Scene 1.
    path = Path()
    path.jump_to(-20, centre[1])
    path.move_straight_to(centre[0], centre[1], 10)
    path.wait(30)
    path.move_straight_to(podium[0], podium[1], 10)
    path.wait(100)

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "WELCOME TO ASCIIMATICS", centre, 30),
        _speak(screen, "My name is Aristotle Arrow.", podium, 110),
        _speak(screen, "I'm here to help you learn ASCIImatics.", podium, 180),
    ]
    scenes.append(Scene(effects))

    # Scene 2.
    path = Path()
    path.jump_to(podium[0], podium[1])

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "Let's start with the Screen...", podium, 10),
        _speak(screen, "This is your Screen object.", podium, 80),
        Print(screen,
              Box(screen.width, screen.height, uni=screen.unicode_aware),
              0,
              0,
              start_frame=90),
        _speak(screen, "It lets you play a Scene like this one I'm in.",
               podium, 150),
        _speak(screen, "A Scene contains one or more Effects.", podium, 220),
        _speak(screen, "Like me - I'm a Sprite!", podium, 290),
        _speak(screen, "Or these Stars.", podium, 360),
        _speak(screen, "As you can see, the Screen handles them both at once.",
               podium, 430),
        _speak(screen, "It can handle as many Effects as you like.", podium,
               500),
        _speak(screen, "Please press <SPACE> now.", podium, 570),
        Stars(screen, (screen.width + screen.height) // 2, start_frame=360)
    ]
    scenes.append(Scene(effects, -1))

    # Scene 3.
    path = Path()
    path.jump_to(podium[0], podium[1])

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "This is a new Scene.", podium, 10),
        _speak(
            screen, "The Screen stops all Effects and clears itself between "
            "Scenes.", podium, 70),
        _speak(screen, "That's why you can't see the Stars now.", podium, 130),
        _speak(screen, "(Though you can override that if you need to.)",
               podium, 200),
        _speak(screen, "Please press <SPACE> now.", podium, 270),
    ]
    scenes.append(Scene(effects, -1))

    # Scene 4.
    path = Path()
    path.jump_to(podium[0], podium[1])

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "So, how do you design your animation?", podium, 10),
        _speak(screen, "1) Decide on your cinematic flow of Scenes.", podium,
               80),
        _speak(screen, "2) Create the Effects in each Scene.", podium, 150),
        _speak(screen, "3) Pass the Scenes to the Screen to play.", podium,
               220),
        _speak(screen, "It really is that easy!", podium, 290),
        _speak(screen, "Just look at this sample code.", podium, 360),
        _speak(screen, "Please press <SPACE> now.", podium, 430),
    ]
    scenes.append(Scene(effects, -1))

    # Scene 5.
    path = Path()
    path.jump_to(podium[0], podium[1])

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "There are various effects you can use.  For "
               "example...", podium, 10),
        Cycle(screen,
              FigletText("Colour cycling"),
              centre[1] - 5,
              start_frame=100),
        Cycle(screen,
              FigletText("using Figlet"),
              centre[1] + 1,
              start_frame=100),
        _speak(screen, "Look in the effects module for more...", podium, 290),
        _speak(screen, "Please press <SPACE> now.", podium, 360),
    ]
    scenes.append(Scene(effects, -1))

    # Scene 6.
    path = Path()
    path.jump_to(podium[0], podium[1])
    curve_path = []
    for i in range(0, 11):
        curve_path.append(
            (centre[0] + (screen.width / 4 * math.sin(i * math.pi / 5)),
             centre[1] - (screen.height / 4 * math.cos(i * math.pi / 5))))
    path2 = Path()
    path2.jump_to(centre[0], centre[1] - screen.height // 4)
    path2.move_round_to(curve_path, 60)

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "Sprites (like me) are also an Effect.", podium, 10),
        _speak(screen, "We take a pre-defined Path to follow.", podium, 80),
        _speak(screen, "Like this one...", podium, 150),
        Plot(screen,
             path2,
             colour=Screen.COLOUR_BLUE,
             start_frame=160,
             stop_frame=300),
        _speak(screen, "My friend Sam will now follow it...", podium, 320),
        Sam(screen, copy.copy(path2), start_frame=380),
        _speak(screen, "Please press <SPACE> now.", podium, 420),
    ]
    scenes.append(Scene(effects, -1))

    # Scene 7.
    path = Path()
    path.jump_to(podium[0], podium[1])
    path.wait(60)
    path.move_straight_to(-5, podium[1], 20)
    path.wait(300)

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "Goodbye!", podium, 10),
        Cycle(screen, FigletText("THE END!"), centre[1] - 4, start_frame=100),
        Print(screen,
              SpeechBubble("Press X to exit"),
              centre[1] + 6,
              start_frame=150)
    ]
    scenes.append(Scene(effects, 500))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 24
0
def demo(screen):
    render = Rainbow(screen, SpeechBubble('D - C R Y P T O R'))
    effects = [RandomNoise(screen, signal=render)]
    screen.play([Scene(effects, 280)], stop_on_resize=True, repeat=False)
Ejemplo n.º 25
0
def _credits(screen):
    scenes = []

    text = Figlet(font="banner", width=200).renderText("ASCIIMATICS")
    width = max([len(x) for x in text.split("\n")])

    effects = [
        Print(screen,
              Fire(screen.height, 80, text, 0.4, 40, screen.colours),
              0,
              speed=1,
              transparent=False),
        Print(screen,
              FigletText("ASCIIMATICS", "banner"),
              screen.height - 9,
              x=(screen.width - width) // 2 + 1,
              colour=Screen.COLOUR_BLACK,
              bg=Screen.COLOUR_BLACK,
              speed=1),
        Print(screen,
              FigletText("ASCIIMATICS", "banner"),
              screen.height - 9,
              colour=Screen.COLOUR_WHITE,
              bg=Screen.COLOUR_WHITE,
              speed=1),
    ]
    scenes.append(Scene(effects, 100))

    effects = [
        Matrix(screen, stop_frame=200),
        Mirage(screen,
               FigletText("Asciimatics"),
               screen.height // 2 - 3,
               Screen.COLOUR_GREEN,
               start_frame=100,
               stop_frame=200),
        Wipe(screen, start_frame=150),
        Cycle(screen,
              FigletText("Asciimatics"),
              screen.height // 2 - 3,
              start_frame=200)
    ]
    scenes.append(Scene(effects, 250, clear=False))

    effects = [
        BannerText(
            screen,
            Rainbow(
                screen,
                FigletText("Reliving the 80s in glorious ASCII text...",
                           font='slant')), screen.height // 2 - 3,
            Screen.COLOUR_GREEN)
    ]
    scenes.append(Scene(effects))

    effects = [
        Mirage(screen, FigletText("Conceived and"), screen.height,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("written by:"), screen.height + 8,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Peter Brittain"), screen.height + 16,
               Screen.COLOUR_GREEN),
        Scroll(screen, 3)
    ]
    scenes.append(Scene(effects, (screen.height + 24) * 3))

    effects = [
        Mirage(screen, FigletText("With help from:"), screen.height,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Cory Benfield"), screen.height + 8,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Bryce Guinta"), screen.height + 16,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Aman Orazaev"), screen.height + 24,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Daniel Kerr"), screen.height + 32,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Dylan Janeke"), screen.height + 40,
               Screen.COLOUR_GREEN),
        Scroll(screen, 3)
    ]
    scenes.append(Scene(effects, (screen.height + 48) * 3))

    effects = [
        Cycle(screen,
              FigletText("ASCIIMATICS", font='big'),
              screen.height // 2 - 8,
              stop_frame=100),
        Cycle(screen,
              FigletText("ROCKS!", font='big'),
              screen.height // 2 + 3,
              stop_frame=100),
        Stars(screen, (screen.width + screen.height) // 2, stop_frame=100),
        DropScreen(screen, 100, start_frame=100)
    ]
    scenes.append(Scene(effects, 200))

    effects = [
        Print(screen,
              SpeechBubble("Press 'X' to exit."),
              screen.height // 2 - 1,
              attr=Screen.A_BOLD)
    ]
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 26
0
 def _speak(self, screen, text, pos):
     return Print(screen,
                  SpeechBubble(text),
                  x=pos[0] + 4,
                  y=pos[1] - 4,
                  colour=Screen.COLOUR_CYAN)
Ejemplo n.º 27
0
def demo(screen):
    render = Rainbow(screen, SpeechBubble('Gaurav D. Sharma'))
    effects = [RandomNoise(screen, signal=render)]
    screen.play([Scene(effects, -1)], stop_on_resize=True)
Ejemplo n.º 28
0
def demo(screen):
    scenes = []
    effects = [
        Stars(screen, screen.width),
        Print(screen,
              SpeechBubble("Press space to see it again"),
              y=screen.height - 3,
              start_frame=300)
    ]
    effects.append(
        Print(
            screen,
            Rainbow(screen, FigletText("3", font='roman')),
            screen.height // 2,
            speed=0.5,
            start_frame=0,
            clear=True,
            stop_frame=30,
        ))
    effects.append(
        Print(
            screen,
            Rainbow(screen, FigletText("2", font='roman')),
            screen.height // 2,
            speed=0.5,
            start_frame=35,
            clear=True,
            stop_frame=70,
        ))
    effects.append(
        Print(
            screen,
            Rainbow(screen, FigletText("1", font='roman')),
            screen.height // 2,
            speed=0.5,
            start_frame=75,
            clear=True,
            stop_frame=100,
        ))

    for _ in range(70):
        fireworks = [(PalmFirework, 25, 30), (PalmFirework, 25, 30),
                     (StarFirework, 20, 35), (StarFirework, 25, 35),
                     (StarFirework, 20, 35), (RingFirework, 30, 30),
                     (SerpentFirework, 35, 35), (SerpentFirework, 35, 35)]
        firework, start, stop = choice(fireworks)
        effects.append(
            firework(screen,
                     randint(0, screen.width),
                     randint(screen.height // 8, screen.height * 3 // 4),
                     randint(start, stop),
                     start_frame=randint(100, 250)))

    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("HAPPY", font='roman')),
              screen.height // 2 - 8,
              speed=1,
              start_frame=100))
    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("NEW YEAR !", font='roman')),
              screen.height // 2,
              speed=1,
              start_frame=100))
    effects.append(
        Print(screen,
              Rainbow(screen, FigletText("2021", font='roman')),
              screen.height // 2 + 8,
              speed=1,
              start_frame=100))
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 29
0
def _credits(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)
    curve_path = []
    for i in range(0, 11):
        curve_path.append(
            (centre[0] + (screen.width / 3 * math.sin(i * math.pi / 5)),
             centre[1] - (screen.height / 3 * math.cos(i * math.pi / 5))))
    path = Path()
    path.jump_to(-20, centre[1] - screen.height // 3)
    path.move_straight_to(centre[0], centre[1] - screen.height // 3, 10),
    path.wait(30)
    path.move_round_to(curve_path, 80)
    path.wait(30)
    path.move_straight_to(7, 4, 10)
    path.wait(300)

    effects = [
        Sam(screen, path),
        Print(screen,
              SpeechBubble("WELCOME TO ASCIIMATICS", "L"),
              x=centre[0] + 12,
              y=(centre[1] - screen.height // 3) - 4,
              colour=Screen.COLOUR_CYAN,
              clear=True,
              start_frame=20,
              stop_frame=50),
        Print(screen,
              SpeechBubble("Wheeeeeee!"),
              y=centre[1],
              colour=Screen.COLOUR_CYAN,
              clear=True,
              start_frame=100,
              stop_frame=250),
        Print(screen,
              SpeechBubble("A world of possibilities awaits you...", "L"),
              x=18,
              y=0,
              colour=Screen.COLOUR_CYAN,
              clear=True,
              start_frame=350,
              stop_frame=400),
        Print(screen,
              ImageFile("globe.gif", colours=screen.colours),
              0,
              start_frame=400),
    ]
    scenes.append(Scene(effects, 600))

    effects = [
        Matrix(screen, stop_frame=200),
        Mirage(screen,
               FigletText("Asciimatics"),
               screen.height // 2 - 3,
               Screen.COLOUR_GREEN,
               start_frame=100,
               stop_frame=200),
        Wipe(screen, start_frame=150),
        Cycle(screen,
              FigletText("Asciimatics"),
              screen.height // 2 - 3,
              start_frame=200)
    ]
    scenes.append(Scene(effects, 250, clear=False))

    effects = [
        BannerText(
            screen,
            Rainbow(
                screen,
                FigletText("Reliving the 80s in glorious ASCII text...",
                           font='slant')), screen.height // 2 - 3,
            Screen.COLOUR_GREEN)
    ]
    scenes.append(Scene(effects))

    effects = [
        Mirage(screen, FigletText("Conceived and"), screen.height,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("written by:"), screen.height + 8,
               Screen.COLOUR_GREEN),
        Mirage(screen, FigletText("Peter Brittain"), screen.height + 16,
               Screen.COLOUR_GREEN),
        Scroll(screen, 3)
    ]
    scenes.append(Scene(effects, (screen.height + 24) * 3))

    effects = [
        Cycle(screen, FigletText("ASCIIMATICS", font='big'),
              screen.height // 2 - 8),
        Cycle(screen, FigletText("ROCKS!", font='big'),
              screen.height // 2 + 3),
        Stars(screen, (screen.width + screen.height) // 2)
    ]
    scenes.append(Scene(effects, 200))

    screen.play(scenes, stop_on_resize=True)
Ejemplo n.º 30
0
def demo(screen):
    screen.set_title("ASCIIMATICS demo")

    scenes = []

    # First scene: title page
    effects = [
        Print(screen,
              Rainbow(screen, FigletText("ASCIIMATICS", font="big")),
              y=screen.height // 4 - 5),
        Print(screen,
              FigletText("Particle System"),
              screen.height // 2 - 3),
        Print(screen,
              FigletText("Effects Demo"),
              screen.height * 3 // 4 - 3),
        Print(screen,
              SpeechBubble("Press SPACE to continue..."),
              screen.height - 3,
              transparent=False,
              start_frame=70)
    ]
    scenes.append(Scene(effects, -1))

    # Next scene: just dissolve the title.
    effects = [
        ShootScreen(screen, screen.width // 2, screen.height // 2, 100),
    ]
    scenes.append(Scene(effects, 40, clear=False))

    # Next scene: sub-heading.
    effects = [
        DropScreen(screen, 100),
        Print(screen,
              Rainbow(screen, FigletText("Explosions", font="doom")),
              y=screen.height // 2 - 5,
              stop_frame=30),
        DropScreen(screen, 100, start_frame=30)
    ]
    scenes.append(Scene(effects, 80))

    # Next scene: explosions
    effects = []
    for _ in range(20):
        effects.append(
            Explosion(screen,
                      randint(3, screen.width - 4),
                      randint(1, screen.height - 2),
                      randint(20, 30),
                      start_frame=randint(0, 250)))
    effects.append(Print(screen,
                         SpeechBubble("Press SPACE to continue..."),
                         screen.height - 6,
                         speed=1,
                         transparent=False,
                         start_frame=100))
    scenes.append(Scene(effects, -1))

    # Next scene: sub-heading.
    effects = [
        Print(screen,
              Rainbow(screen, FigletText("Rain", font="doom")),
              y=screen.height // 2 - 5,
              stop_frame=30),
        DropScreen(screen, 100, start_frame=30)
    ]
    scenes.append(Scene(effects, 80))

    # Next scene: rain storm.
    effects = [
        Rain(screen, 200),
        Print(screen,
              SpeechBubble("Press SPACE to continue..."),
              screen.height - 6,
              speed=1,
              transparent=False,
              start_frame=100)
    ]
    scenes.append(Scene(effects, -1))

    # Next scene: sub-heading.
    effects = [
        Print(screen,
              Rainbow(screen, FigletText("Fireworks", font="doom")),
              y=screen.height // 2 - 5,
              stop_frame=30),
        DropScreen(screen, 100, start_frame=30)
    ]
    scenes.append(Scene(effects, 80))

    # Next scene: fireworks
    effects = []
    for _ in range(20):
        effects.append(
            StarFirework(screen,
                         randint(3, screen.width - 4),
                         randint(1, screen.height - 2),
                         randint(20, 30),
                         start_frame=randint(0, 250)))
    effects.append(Print(screen,
                         SpeechBubble("Press SPACE to continue..."),
                         screen.height - 6,
                         speed=1,
                         transparent=False,
                         start_frame=100))
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)