[Python] I tried to reproduce the emergency escape program to return from the world to return from the modified world of "The disappearance of Haruhi Suzumiya"

I made a memorial service because I made something that I didn't have.

What I made

image.png I tried to reproduce the emergency escape program that appears in the movie "The Disappearance of Haruhi Suzumiya".

image.png As in the work, the characters are output one by one in order.

The end of the code ends with "input ()", so when you press the enter key, the prompt disappears. During the work, Kyon returned from the altered world the moment he pressed the enter key, the people who were supposed to be in the club room disappeared, and the prompt that was supposed to be on the PC screen disappeared.

As expected, I couldn't write a program to erase the people around me, but I made it possible to erase the prompt with the enter key, so I feel like I've moved from the modified world to play alone.

Source code

from time import sleep

#The character given to the argument is YUKI.Display like N
def yuki_n(*message, speed=0.15):
    count = 0 #Variable to assign after what line has been output
    name = "YUKI. N>"

    #Processing to be performed on the output of the first line
    msg = message[0]

    #Show name
    for s in range(len(name)):
        print(name[0:s+1]+"\r",end="")
        sleep(speed)

    for i in range(len(msg)):
        #For the last character of a line, do not add _ at the end of the sentence
        if i == len(msg)-1:
            print(name + msg)
            sleep(speed)
            count += 1

        else:
            print(name + msg[0:i+1],end="")
            print("_"+"\r",end="")
            sleep(speed)
        
    #Processing to be performed if there is output from the second line onward
    if len(message) > 1:
        for msg in message[1:]:
            for i in range(len(msg)):
                    #For the last character of a line, do not add _ at the end of the sentence
                    if i == len(msg)-1:
                        print("       " + msg)
                        sleep(speed)
                        count += 1

                    else:
                        print("       " + msg[0:i+1],end="")
                        print("_"+"\r",end="")
                        sleep(speed)
    
    #Line break after printing the last line
    if count == len(message):
        print("")


#Display "Ready?"
def ready(speed=0.5):
    ready = "Ready?"
    #「_Flashes
    for _ in range(2):
        print("       " + "_"+"\r",end="")
        sleep(speed)
        print("       " + " "+"\r",end="")
        sleep(speed)
    
    print("       " + "_"+"\r",end="")
    sleep(speed)

    for s in range(len(ready)):
        print("       " + ready[0:s] + "_" + "\r",end="")
        sleep(0.15)
    print("       " + ready,end="")


#When starting a new line, use yuki as multiple arguments_pass to n function
yuki_n("When you are reading this","I will not be me.")
yuki_n("If this message is displayed,","There you, me, Haruhi Suzumiya, Mikuru Asahina,","Kazuki Koizumi should exist.")
yuki_n("That is the key.","You have found the answer.")
yuki_n("This is an emergency escape program."," ","To start it, press the enter key,","If not, select another key."," ","When started,"\
    ,"You get the opportunity to correct space-time.","However, success cannot be guaranteed.","In addition, we cannot guarantee the return.")
yuki_n("This program only starts once.","After execution, it will be erased."," ","If non-execution is selected, it will be deleted without starting."," ")
ready()

input()

It's a simple program that just uses a carriage return. For how to use the carriage return, refer to "How to display the terminal output of the print function in Python by overwriting one line". became.

Other

Since the character output is a function called "yuki_n", it depends on the character passed to the argument. image.png You can also do something like that. It's not "Ready?" It's scary.

Recommended Posts

[Python] I tried to reproduce the emergency escape program to return from the world to return from the modified world of "The disappearance of Haruhi Suzumiya"
I tried to summarize the string operations of Python
I tried to find the entropy of the image with python
[Python] I tried to visualize the follow relationship of Twitter
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I tried to improve the efficiency of daily work with Python
I tried to get the authentication code of Qiita API with Python.
(Python) I tried to analyze 1 million hands ~ I tried to estimate the number of AA ~
I tried to verify and analyze the acceleration of Python by Cython
I tried to streamline the standard role of new employees with Python
I tried to get the movie information of TMDb API with Python
I made a program to check the size of a file in Python
I tried to deliver mail from Node.js and Python using the mail delivery service (SendGrid) of IBM Cloud!
[Python] I tried to judge the member image of the idol group using Keras
I tried to touch the API of ebay
I tried to correct the keystone of the image
I tried to easily visualize the tweets of JAWS DAYS 2017 with Python + ELK
I tried to automate the 100 yen deposit of Rakuten horse racing (python / selenium)
[IBM Cloud] I tried to access the Db2 on Cloud table from Cloud Funtions (python)
[Python] I tried to get the type name as a string from the type function
I tried to refactor the code of Python beginner (junior high school student)
I tried to execute Python code from .Net using Pythonnet (Hallo World edition)
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to predict the price of ETF
I tried to vectorize the lyrics of Hinatazaka46!
I tried to extract various information of remote PC from Python by WMI Library
Python practice 100 knocks I tried to visualize the decision tree of Chapter 5 using graphviz
I tried to automate the article update of Livedoor blog with Python and selenium.
I tried to sort out the objects from the image of the steak set meal-④ Clustering
I used Python to find out about the role choices of the 51 "Yachts" in the world.
I tried to compare the processing speed with dplyr of R and pandas of Python
The 15th offline real-time I tried to solve the problem of how to write with python
python beginners tried to predict the number of criminals
I tried to graph the packages installed in Python
I tried to summarize how to use matplotlib of python
I tried to detect the iris from the camera image
I tried to summarize the basic form of GPLVM
I tried to touch the CSV file with Python
Study from the beginning of Python Hour1: Hello World
Get the return code of the Python script from bat
I wanted to use the Python library from MATLAB
[Python] I tried to graph the top 10 eyeshadow rankings
I tried to visualize the spacha information of VTuber
I tried to erase the negative part of Meros
I tried to solve the problem with Python Vol.1
[Python] I tried to get Json of squid ring 2
I tried to classify the voices of voice actors
I tried the python version of "Consideration of Conner Davis's answer" Printing numbers from 1 to 100 without using loops, recursion, and goto "
How to write offline real time I tried to solve the problem of F02 with Python
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I tried to analyze the data of the soccer FIFA World Cup Russia tournament with soccer action
I tried to create a Python script to get the value of a cell in Microsoft Excel
I tried to predict the genre of music from the song title on the Recurrent Neural Network
I wrote a doctest in "I tried to simulate the probability of a bingo game with Python"
I tried to sort out the objects from the image of the steak set meal-① Object detection
Implementation of recommendation system ~ I tried to find the similarity from the outline of the movie using TF-IDF ~
I tried to find the trend of the number of ships in Tokyo Bay from satellite images.
[Horse Racing] I tried to quantify the strength of racehorses
I tried "gamma correction" of the image with Python + OpenCV
I tried to simulate how the infection spreads with Python
I tried to get the location information of Odakyu Bus