示例#1
0
    def reset(self, old_scene=None, screen=None):
        super(EatingScene, self).reset(old_scene, screen)

        # Recreate all the elements.
        centre = (self._screen.width // 2, self._screen.height // 2)
        path = Path()
        path.jump_to(-16, centre[1])
        path.move_straight_to(self._screen.width + 16, centre[1],
                              (self._screen.width + 16) // 3)
        path.wait(100)
        path2 = Path()
        path2.jump_to(-16, centre[1])
        path2.move_straight_to(self._screen.width + 16, centre[1],
                               self._screen.width + 16)
        path2.wait(100)

        # Take a copy of the list before using it to remove all effects.
        for effect in self.effects[:]:
            self.remove_effect(effect)

        self.add_effect(ScaredGhost(self._screen, deepcopy(path2)))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=60))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=120))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=180))
        self.add_effect(PacMan(self._screen, path, start_frame=240))
示例#2
0
    def reset(self, old_scene=None, screen=None):
        super(EatingScene, self).reset(old_scene, screen)

        # Recreate all the elements.
        centre = (self._screen.width // 2, self._screen.height // 2)
        path = Path()
        path.jump_to(-16, centre[1])
        path.move_straight_to(
            self._screen.width + 16, centre[1], (self._screen.width + 16) // 3)
        path.wait(100)
        path2 = Path()
        path2.jump_to(-16, centre[1])
        path2.move_straight_to(
            self._screen.width + 16, centre[1], self._screen.width + 16)
        path2.wait(100)

        for effect in self.effects:
            self.remove_effect(effect)

        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2)))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=60))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=120))
        self.add_effect(
            ScaredGhost(self._screen, deepcopy(path2), start_frame=180))
        self.add_effect(PacMan(self._screen, path, start_frame=240))
示例#3
0
 def test_jump_and_wait(self):
     """
     Check basic movement of cursor works.
     """
     path = Path()
     path.jump_to(10, 10)
     path.wait(3)
     self.assertPathEquals(path, [(10, 10), (10, 10), (10, 10), (10, 10)])
示例#4
0
 def test_jump_and_wait(self):
     """
     Check basic movement of cursor works.
     """
     path = Path()
     path.jump_to(10, 10)
     path.wait(3)
     self.assert_path_equals(path, [(10, 10), (10, 10), (10, 10), (10, 10)])
示例#5
0
def demo(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)

    # Title
    effects = [
        BannerText(screen,
                   ColourImageFile(screen, "pacman.png", 16),
                   (screen.height - 16) // 2,
                   Screen.COLOUR_WHITE),
        Print(screen,
              StaticRenderer(images=["A tribute to the classic 80's "
                                     "video game by Namco."]),
              screen.height - 1)
    ]
    scenes.append(Scene(effects, 0))

    # Scene 1 - run away, eating dots
    path = Path()
    path.jump_to(screen.width + 16, centre[1])
    path.move_straight_to(-16, centre[1], (screen.width + 16) // 3)
    path.wait(100)

    if screen.colours <= 16:
        inky = 6
        pinky = 5
        blinky = 1
        clyde = 2
    else:
        inky = 14
        pinky = 201
        blinky = 9
        clyde = 208

    effects = [
        PacMan(screen, path),
        Ghost(screen, deepcopy(path), inky, start_frame=40),
        Ghost(screen, deepcopy(path), pinky, start_frame=60),
        Ghost(screen, deepcopy(path), blinky, start_frame=80),
        Ghost(screen, deepcopy(path), clyde, start_frame=100),
    ]

    for x in range(5, screen.width, 16):
        effects.insert(0,
                       Print(screen,
                             StaticRenderer(images=[dot]),
                             screen.height // 2,
                             x=x,
                             speed=1,
                             stop_frame=4))

    scenes.append(Scene(effects, 100 + screen.width))

    # Scene 2 - Chase ghosts after a power pill
    scenes.append(EatingScene(screen))

    screen.play(scenes, stop_on_resize=True)
示例#6
0
    def eaten(self):
        # Already eaten - just ignore
        if self._eaten:
            return

        # Allow one more iteration for this Sprite to clear itself up.
        self._eaten = True
        self._delete_count = 2

        # Spawn the eyes to run away
        path = Path()
        path.jump_to(self._old_x + 12, self._old_y + 4)
        path.move_straight_to(self._old_x + 12, -8, (self._old_y + 12) // 2)
        path.wait(10000)
        self._scene.add_effect(Eyes(self._screen, path))
示例#7
0
    def eaten(self):
        # Already eaten - just ignore
        if self._eaten:
            return

        # Allow one more iteration for this Sprite to clear itself up.
        self._eaten = True
        self._delete_count = 2

        # Spawn the eyes to run away
        path = Path()
        path.jump_to(self._old_x + 12, self._old_y + 4)
        path.move_straight_to(
            self._old_x + 12, -8, (self._old_y + 12) // 2)
        path.wait(100)
        self._scene.add_effect(Eyes(self._screen, path))
示例#8
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)
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, "Secure TLS Deployment with LURK  \n" +\
                       "-- Example: RSA Authentication --", centre, 30),
    ]
    scenes.append(Scene(effects))

    # Scene 2
    T = 0
    path = Path()
    path.jump_to(podium[0], podium[1])
    effects = [Arrow(screen, path, colour=Screen.COLOUR_GREEN)]
    Y = 8

    speak = "In practice the line between Untrusted and " +\
          "Trusted Domain does not exist..."
    labels = ["Untrusted Domain", "Trusted Domain"]
    colors = [Screen.COLOUR_RED, Screen.COLOUR_GREEN]
    effects += [_speak(screen, speak, podium, T)]
    effects += _background_display( screen, start=T, stop=T + TIC_SPEAK, labels=labels,\
                  colors=colors, y=Y, mode="header_plain")
    T += TIC_SPEAK

    speak = "Instead there is a continuum with Untrusted, \n" +\
            "Exposed and Trusted Domain...                "
    labels = ["Untrusted Domain", "Exposed Domain", "Trusted Domain"]
    colors = [ Screen.COLOUR_RED, Screen.COLOUR_YELLOW, \
               Screen.COLOUR_GREEN ]
    effects += [_speak(screen, speak, podium, T)]
    effects += _background_display( screen, start=T, stop=T + 3 * TIC_SPEAK, labels=labels,\
                  colors=colors, y=Y, mode="header_plain")
    T += TIC_SPEAK

    speak = "For CDN:                                   \n"+\
            "    * Untrusted Domain == Internet,        \n" + \
            "    * Exposed Domain   == delegated CDN,   \n" +\
            "    * Trusted Domain   ==  Your CDN...     "
    effects += [_speak(screen, speak, podium, T)]
    T += TIC_SPEAK

    speak = "For vRAN:                                                 \n" +\
            "    * Untrusted Domain == Data Center,                    \n" +\
            "    * Exposed Domain   == vRAN Software,                  \n" +\
            "    * Trusted Domain   == Trusted Execution Environment..."
    effects += [_speak(screen, speak, podium, T)]
    T += TIC_SPEAK

    speak = "This can be extended to any case where TLS is used..."
    labels = ["TLS Client", "TLS Server", "Key Server"]
    effects += [_speak(screen, speak, podium, T)]
    effects += _background_display( screen, start=T, stop=END_OF_DEMO, labels=labels,\
                   colors=colors, y=Y, mode="header_plain")
    T += TIC_SPEAK
    Y += 2

    speak = "A TLS Client terminates the session to the Exposed Environment"
    msg = "ClientHello          \n" +\
          "   server_version    \n" +\
          "   client_random     \n" +\
          "   cipher_suite      \n" +\
          "       TLS_RSA_*, ...\n" +\
          "-------->"
    effects += move_h(screen, msg, Y, 'tls_clt', T)
    effects += [_speak(screen, speak, podium, T)]

    speak = "The TLS Server chose RSA authentication proposed by the \n" +\
            "TLS Client                                              "
    effects.append(_speak(screen, speak, podium, T + TIC_SPEAK))
    T += max(TIC_MESSAGE, 2 * TIC_SPEAK)
    Y += msg.count('\n') + 1


    speak = "The TLS Server knows RSA Authentication involves    \n" +\
            "interactions with the Key Server and obfuscates the \n" +\
            "server_random to provide perfect forward secrecy.   "
    effects.append(_speak(screen, speak, podium, T))
    T += TIC_SPEAK

    speak = "The TLS Server:                                           \n" +\
            "     - 1) Generates a server_random                       \n" +\
            "     - 2) Obfuscates the server_random                    \n" +\
            "     - 3) Sends the obfuscated value to the TLS Client    \n" +\
            "     - 4) Sends the non obfuscated value to the Key Server"
    effects.append(_speak(screen, speak, podium, T))

    txt = "LURK server_random:            "
    txt_value = "    gmt_unix_time                \n" +\
                "     random                     "
    kwargs = { "colour" : Screen.COLOUR_YELLOW, "attr" : Screen.A_BOLD, \
               "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True,\
                'x' : int( 1.1 * int(screen.width / 3 ) ), 'start_frame' : T, \
                'stop_frame' : END_OF_DEMO}
    y = Y - 2  # moving up to two lines the text
    args = [screen, s2r(txt), y]
    effects += [Print(*args, **kwargs)]
    kwargs['colour'] = Screen.COLOUR_RED
    args = [screen, s2r(txt_value), y + 1]
    effects += [Print(*args, **kwargs)]
    y += txt.count('\n') + 1 + txt_value.count('\n')

    txt = " Obfuscated TLS server_random: "
    txt_value= "    gmt_unix_time               \n" +\
               "     random                     "
    kwargs = { "colour" : Screen.COLOUR_YELLOW, "attr" : Screen.A_BOLD, \
               "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True,\
                'x' : int( 1.1 * int(screen.width / 3 ) ), 'start_frame' : T, \
                'stop_frame' : END_OF_DEMO}
    args = [screen, s2r(txt), y]
    effects += [Print(*args, **kwargs)]
    kwargs['colour'] = Screen.COLOUR_WHITE
    args = [screen, s2r(txt_value), y + 1]
    effects += [Print(*args, **kwargs)]
    T += TIC_SPEAK

    speak = "The TLS Server responds with a ServerHello \n" +\
            "That includes the obfuscated server_random "
    msg = "ServerHello               \n" +\
          "    tls_version           \n" +\
          "    server_random (TLS)   \n" +\
          "    Cipher_suite=TLS_RSA  \n" +\
          "Certificate               \n" +\
          "    RSA Public Key        \n" +\
          "ServerHelloDone           \n" +\
          "<--------                  "
    effects += move_h(screen, msg, Y, 'tls_srv', T)
    effects += [_speak(screen, speak, podium, T)]
    T += max(TIC_MESSAGE, TIC_SPEAK)
    Y += msg.count('\n') + 1

    speak = "The TLS Client sends a ClientKeyExchange \n" +\
            "with the encrypted premaster             "
    msg = "ClientKeyExchange        \n" +\
          "    encrypted_premaster   \n" +\
          "-------->"
    effects += move_h(screen, msg, Y, 'tls_clt', T)
    effects += [_speak(screen, speak, podium, T)]
    T += max(TIC_MESSAGE, TIC_SPEAK)
    Y += msg.count('\n') + 1

    speak = "Upon receiving the ClientKeyExchange, the \n" +\
            "TLS Server initiates a LURK exchange with \n" +\
            "the Key Server to:                        \n" +\
            "    - 1) Decyrpte the encrypted_premaster \n" +\
            "    - 2) Generate the master_secret       "
    msg = "RSAMasterRequest   \n" +\
          "    key_id             \n" +\
          "        key_id_type    \n" +\
          "        key_id         \n" +\
          "    freshness_funct    \n" +\
          "    client_random      \n" +\
          "        gmt_unix_time  \n" +\
          "        random =       \n" +\
          "    server_random      \n" +\
          "        gmt_unix_time  \n" +\
          "        random =       \n" +\
          "    encrypted_premaster\n" +\
          "-------->             "
    effects.append(_speak(screen, speak, podium, T))
    effects += move_h(screen, msg, Y, 'lurk_clt', T)
    T += max(TIC_MESSAGE, TIC_SPEAK)
    Y += msg.count('\n') + 1

    speak = "The Key Server :                          \n" +\
            "    - 1) Decrypts the encrypted_premaster \n" +\
            "    - 2) Generates the master secret      "
    msg = "RSAMasterResponse\n" +\
          "    master       \n" +\
          "<--------       "
    effects.append(_speak(screen, speak, podium, T))
    effects += move_h(screen, msg, Y, 'lurk_srv', T)
    T += max(TIC_MESSAGE, TIC_SPEAK)
    Y += msg.count('\n') + 1


    speak = "With the master_secret, the TLS Server finalizes \n" +\
            "the authenticated TLS Key Exchange.              \n" +\
            "                                                 \n" +\
            "The TLS Server has not accessed the private key !"
    msg = "[ChangeCipherSpec] \n" +\
          "Finishedit         \n" +\
          "-------->          "
    effects += [_speak(screen, speak, podium, T)]
    effects += move_h(screen, msg, Y, 'tls_clt', T)
    T += max(TIC_MESSAGE, TIC_SPEAK)
    Y += msg.count('\n') + 1

    msg = "[ChangeCipherSpec] \n" +\
          "    Finished       \n" +\
          "<--------          "
    effects += move_h(screen, msg, Y, 'tls_srv', T)
    T += max(TIC_SPEAK, TIC_SPEAK)
    Y += msg.count('\n') + 1

    txt = "Application Data      <------->     Application Data"
    kwargs = { "colour" : Screen.COLOUR_WHITE, "attr" : Screen.A_BOLD, \
               "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True, \
               'x' : int( screen.width  / 3 * ( 0.1 + 1 / 2) - len( txt ) / 2  ), \
               'start_frame' : T, 'stop_frame' : END_OF_DEMO }
    args = [screen, s2r(txt), Y]
    effects.append(Print(*args, **kwargs))
    T += TIC_SPEAK
    Y += txt.count('\n') + 1

    scenes.append(Scene(effects, duration=20000, clear=True))

    #scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
示例#10
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), 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)
示例#11
0
def kitty(screen, scene):
    scenes = []
    effects = [
        ProfileFrame(screen),
    ]
    scenes.append(Scene(effects, -1, name='Main'))

    # scene
    cell = ColourImageFile(screen, 'img/4.jpg', screen.height)
    effects = [
        RandomNoise(screen, signal=cell),
        Print(screen,
              Rainbow(screen, FigletText('Kitty', font='banner')),
              screen.height - 6,
              start_frame=200,
              bg=0),
        Print(screen,
              Rainbow(screen, FigletText('Kitty', font='banner')),
              screen.height - 6,
              start_frame=200,
              bg=0)
    ]
    scenes.append(Scene(effects, 380, name='Begin'))

    # scene
    effects = [ShootScreen(screen, screen.width // 2, screen.height // 2, 100)]
    scenes.append(Scene(effects, 60, clear=False))

    #scene
    centre = ((screen.width // 2) - 20, (screen.height // 2) - 3)
    podium = (8, 5)
    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(180)

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        Snow(screen),
        Rain(screen, 340),
        Print(screen,
              StaticRenderer(images=tree),
              screen.height - 15,
              screen.width - 15,
              colour=Screen.COLOUR_GREEN),
        _speak(
            screen,
            u'This program write for the girl that i like, hope she will be happy!',
            centre, 30),
        _speak(screen,
               u'I like her at the first sight when i met her last year.',
               podium, 110),
        _speak(
            screen,
            u'I really like to chat with her, but afraid that she will be boring. ',
            podium, 180),
        Cycle(screen,
              Rainbow(screen, FigletText('Lovely', 'banner')),
              screen.height // 2 - 6,
              start_frame=220),
        Cycle(screen,
              Rainbow(screen, FigletText('Kitty', 'banner')),
              screen.height // 2 + 1,
              start_frame=220)
    ]
    scenes.append(Scene(effects, duration=340))

    #scene
    cell = ColourImageFile(screen,
                           'img/10.jpg',
                           screen.height,
                           uni=screen.unicode_aware,
                           dither=screen.unicode_aware)
    effects = [
        Wipe(screen),
        Print(screen, cell, 0),
        Stars(screen, screen.height + screen.width)
    ]

    # for _ in  range(20):
    #     effects.append(
    #         Explosion(screen, randint(0, screen.width), randint(screen.height//8, screen.height*3//4), randint(20, 150) )
    #     )

    scenes.append(Scene(effects, 150, clear=False))

    #scene
    cell = ColourImageFile(screen,
                           'img/3.jpg',
                           screen.height,
                           uni=screen.unicode_aware,
                           dither=screen.unicode_aware)
    effects = [
        DropScreen(screen, 100),
        BannerText(screen, cell, 0, Screen.COLOUR_YELLOW),
        Snow(screen)
    ]

    for _ in range(120):
        fireworks = [(PalmFirework, randint(25, 35)),
                     (RingFirework, randint(25, 30)),
                     (StarFirework, randint(30, 35)),
                     (SerpentFirework, randint(28, 35))]
        firework, lifetime = choice(fireworks)
        effects.append(
            firework(screen,
                     randint(0, screen.width),
                     randint(screen.height // 8, screen.height * 3 // 4),
                     lifetime,
                     start_frame=randint(20, 250)))
    scenes.append(Scene(effects, 280, clear=False))

    #scene
    cell = ColourImageFile(screen,
                           'img/1.jpg',
                           screen.height,
                           uni=screen.unicode_aware,
                           dither=screen.unicode_aware)
    effects = [
        Print(screen, cell, 0, speed=1),
        Scroll(screen, rate=10),
        Rain(screen, 200)
    ]
    scenes.append(Scene(effects, 180))

    #scene
    text = Figlet(font="banner", width=200).renderText("Pretty Girl")
    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),
        Print(screen,
              FigletText("Pretty Girl", 'banner'),
              screen.height - 9,
              x=(screen.width - width) // 2 + 1,
              colour=0,
              bg=0,
              speed=1),
        Print(screen,
              FigletText("Pretty Girl", 'banner'),
              screen.height - 9,
              x=(screen.width - width) // 2 + 1,
              colour=7,
              bg=7,
              speed=1)
    ]
    scenes.append(Scene(effects, 80))

    #scene
    effects = [
        Print(screen,
              Plasma(screen.height, screen.width, screen.colours),
              0,
              speed=1,
              start_frame=50),
        Print(screen, Rainbow(screen, FigletText('Thats All')),
              screen.height // 2 - 5),
        Print(screen, Rainbow(screen, FigletText('My Kitty!')),
              screen.height // 2 + 5),
    ]
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True, start_scene=scene)
示例#12
0
def demo(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)

    # Title
    effects = [
        BannerText(screen, ColourImageFile(screen, "pacman.png", 16, 0, True),
                   (screen.height - 16) // 2, Screen.COLOUR_WHITE),
        Print(
            screen,
            StaticRenderer(images=[
                "A tribute to the classic 80's "
                "video game by Namco."
            ]), screen.height - 1)
    ]
    #scenes.append(Scene(effects, 0))

    # Scene 1 - run away, eating dots
    path = Path()
    path.jump_to(screen.width + 16, centre[1])
    path.move_straight_to(-16, centre[1], (screen.width + 16) // 3)
    path.wait(100)

    if screen.colours <= 16:
        inky = 6
        pinky = 5
        blinky = 1
        clyde = 2
    else:
        inky = 14
        pinky = 201
        blinky = 9
        clyde = 208

    effects = [
        PacMan(screen, path),
        Ghost(screen, deepcopy(path), inky, start_frame=40),
        Ghost(screen, deepcopy(path), pinky, start_frame=60),
        Ghost(screen, deepcopy(path), blinky, start_frame=80),
        Ghost(screen, deepcopy(path), clyde, start_frame=100),
    ]

    for x in range(5, screen.width, 16):
        effects.insert(
            0,
            Print(screen,
                  StaticRenderer(images=[dot]),
                  screen.height // 2,
                  x=x,
                  speed=1,
                  stop_frame=4))

    scenes.append(Scene(effects, 100 + screen.width))

    # Scene 2 - Chase ghosts after a power pill
    scenes.append(EatingScene(screen))

    # Scene 3 - Thanks...
    effects = [
        Print(screen,
              FigletText("Thank you,"),
              screen.height // 3 - 3,
              colour=Screen.COLOUR_RED),
        Print(screen,
              StaticRenderer(images=[namco]),
              screen.height * 2 // 3 - 2,
              colour=Screen.COLOUR_RED),
        Print(screen, StaticRenderer(images=["< Press X to exit. >"]),
              screen.height - 1)
    ]
    scenes.append(Scene(effects, 0))

    screen.play(scenes, stop_on_resize=True, repeat=False)
示例#13
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)
示例#14
0
def get_game(game_index, centre, screen):
    if game_index == 1:
        left_path = Path()
        left_path.jump_to(centre[0] - 9, centre[1] + 2)
        left_path.move_straight_to(centre[0] - 9, centre[1] - 1, 10),
        left_path.move_straight_to(centre[0], centre[1] - 1, 10),
        left_path.move_straight_to(centre[0], centre[1] + 2, 10),
        left_path.is_finished

        middle_path = Path()
        middle_path.jump_to(centre[0], centre[1] + 2)
        middle_path.wait(15)
        middle_path.move_straight_to(centre[0] - 9, centre[1] + 2, 10)
        middle_path.wait(50)
        middle_path.is_finished

        effects = [
            Shell(screen, left_path),
            Shell(screen, middle_path),
            Print(screen,
                  StaticRenderer(images=[shell]),
                  x=centre[0] + 7,
                  y=centre[1])
        ]
        return (Scene(effects, 66), 1)
    elif game_index == 2:
        right_path = Path()
        right_path.jump_to(centre[0] + 7, centre[1] + 2)
        right_path.move_straight_to(centre[0] + 7, centre[1] - 1, 10),
        right_path.move_straight_to(centre[0], centre[1] - 1, 10),
        right_path.move_straight_to(centre[0], centre[1] + 2, 10),
        right_path.is_finished

        middle_path = Path()
        middle_path.jump_to(centre[0], centre[1] + 2)
        middle_path.wait(15)
        middle_path.move_straight_to(centre[0] + 7, centre[1] + 2, 10)
        middle_path.wait(50)
        middle_path.is_finished

        effects = [
            Shell(screen, right_path),
            Shell(screen, middle_path),
            Print(screen,
                  StaticRenderer(images=[shell]),
                  x=centre[0] - 9,
                  y=centre[1])
        ]
        return (Scene(effects, 66), 3)
    elif game_index == 3:
        right_path = Path()
        right_path.jump_to(centre[0] + 7, centre[1] + 2)
        right_path.move_straight_to(centre[0] + 7, centre[1] - 1, 10),
        right_path.move_straight_to(centre[0] - 9, centre[1] - 1, 20),
        right_path.move_straight_to(centre[0] - 9, centre[1] + 2, 10),
        right_path.is_finished

        middle_path = Path()
        middle_path.jump_to(centre[0], centre[1] + 2)
        middle_path.wait(15)
        middle_path.move_straight_to(centre[0] + 7, centre[1] + 2, 10)
        middle_path.wait(50)
        middle_path.is_finished

        left_path = Path()
        left_path.jump_to(centre[0] - 9, centre[1] + 2)
        left_path.wait(15)
        left_path.move_straight_to(centre[0], centre[1] + 2, 10)
        left_path.wait(50)
        left_path.is_finished

        effects = [
            Shell(screen, right_path),
            Shell(screen, middle_path),
            Shell(screen, left_path)
        ]
        return (Scene(effects, 85), 3)
    elif game_index == 4:
        right_path = Path()
        right_path.jump_to(centre[0] + 7, centre[1] + 2)
        right_path.wait(15)
        right_path.move_straight_to(centre[0], centre[1] + 2, 10),
        right_path.wait(50)
        right_path.is_finished

        middle_path = Path()
        middle_path.jump_to(centre[0], centre[1] + 2)
        middle_path.wait(15)
        middle_path.move_straight_to(centre[0] - 9, centre[1] + 2, 10)
        middle_path.wait(50)
        middle_path.is_finished

        left_path = Path()
        left_path.jump_to(centre[0] - 9, centre[1] + 2)
        left_path.move_straight_to(centre[0] - 9, centre[1] - 1, 10)
        left_path.move_straight_to(centre[0] + 7, centre[1] - 1, 20)
        left_path.move_straight_to(centre[0] + 7, centre[1] + 2, 10)
        left_path.wait(50)
        left_path.is_finished

        effects = [
            Shell(screen, right_path),
            Shell(screen, middle_path),
            Shell(screen, left_path)
        ]
        return (Scene(effects, 85), 1)
示例#15
0
def demo(screen):
    scenes = []
    centre = (screen.width // 2, screen.height // 2)
    podium = (38, 20, 30, 20)
    podium2 = (30, 20)

    # 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, "BIENVENIDO A  ~~THE MINERS~~~ !!!", centre, 30),
        _speak(screen, "Tercera parte de Postdigital (Enrique Tomás).", podium,
               110),
        _speak(screen, "Quiero explicarte algo sobre la obra.", podium, 180),
    ]
    scenes.append(Scene(effects))

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

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "The Miners? ... ¿Los mineros?", podium, 10),
        _speak(screen, "Va sobre las criptomonedas y sus efectos...", podium,
               80),
        #Print(screen,
        #      Box(screen.width, screen.height, uni=screen.unicode_aware),
        #      0, 0, start_frame=90),
        _speak(screen, "Las criptomonedas son dinero electrónico.", podium,
               150),
        _speak(
            screen,
            "Sirven para transferir dinero sin intermediarios (como los bancos).",
            podium, 220),
        _speak2(
            screen,
            "Las transacciones necesitan ser verificadas por otros ordenadores de la red",
            podium, 300),
        _speak(screen, "que resuelven un complejo problema matemático.",
               podium, 400),
        _speak(screen, "...consumiendo mucha electricidad.", podium, 480),
        _speak2(screen, "Al año, tanta como un país como Irlanda o Suiza.",
                podium, 580),
        _speak(screen,
               "Por este motivo se recompensa económicamente a los nodos.",
               podium, 700),
        _speak2(
            screen,
            "El primero en resolverlo gana 12.5 bitcoins (1 bitcoin =~ 4200 euro) ",
            podium, 780),
        Stars(screen, (screen.width + screen.height) // 2, start_frame=360)
    ]
    scenes.append(Scene(effects, -1))

    # Scene 3.
    path = Path()
    path.move_straight_to(podium[2], podium[3], 10)
    path.wait(800)

    effects = [
        Arrow(screen, path, colour=Screen.COLOUR_GREEN),
        _speak(screen, "Durante esta obra, vamos a minar bitcoins...", podium2,
               10),
        _speak2(screen, "Cada nota que tocará el Emsemble Container...",
                podium2, 70),
        _speak2(
            screen,
            "verificará (minará) una transaccion de bitcoins en tiempo real",
            podium2, 160),
        _speak(screen, " y si tenemos suerte (1 elevado a menos 36)...",
               podium2, 260),
        _speak(screen, "¡¡¡ganaremos 12.5 bitcoins en este concierto!!!",
               podium2, 340),
        _speak(screen, "El minado (ejem... el concierto) va a empezar...",
               podium2, 420),
        RandomNoise(screen,
                    signal=Rainbow(
                        screen,
                        FigletText("El concierto... va a empezar...",
                                   font="term")),
                    start_frame=490)
    ]
    scenes.append(Scene(effects, -1))

    screen.play(scenes, stop_on_resize=True)
示例#16
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)