Exemple #1
0
def demo(screen):
    effects = [
        Cycle(screen, FigletText("50th anniversary of APOLLO 11", font='big'),
              screen.height // 2 - 8),
        Stars(screen, (screen.width + screen.height) // 2),
        RingFirework(screen, 10, 10, 50),
        StarFirework(screen, 40, 8, 50),
        RingFirework(screen, 70, 12, 50),
        RingFirework(screen, 100, 10, 50),
        StarFirework(screen, 130, 8, 50),
        RingFirework(screen, 160, 12, 50)
    ]
    screen.play([Scene(effects, 100)], ExplosionFlames(screen, 44, 20, 100))
Exemple #2
0
def _fireworks(screen):
    effects = []
    x_regions = [
        (0, screen.width),
        (0, screen.width // 3),
        (screen.width // 3 * 2, screen.width),
    ]
    y_regions = [
        (0, screen.height),
        (screen.height // 2, screen.height),
    ]

    for _ in range(20):
        x = randint(*choice(x_regions))
        y = randint(*choice(y_regions))
        effects.insert(
            1,
            StarFirework(
                screen,
                x,
                y,
                randint(25, 30),
                start_frame=randint(0, 250),
            ),
        )
    return effects
Exemple #3
0
 def test_star_firework(self):
     """
     Test that StarFirework works as expected.
     """
     screen = MagicMock(spec=Screen, colours=8)
     canvas = Canvas(screen, 10, 40, 0, 0)
     effect = StarFirework(canvas, 4, 4, 25)
     self.check_effect(canvas,
                       effect,
                       lambda value: self.assertIn(chr(value[0]), '|+:,. '),
                       iterations=25)
Exemple #4
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)