I made something with python that NOW LOADING moves from left to right on the terminal

What is this program?

When playing games, the letters NOW LOADING are in the lower right corner, I think there are some who move from left to right and some characters are bigger, but that's it. I'm sorry if you don't understand.

The code is written in python3. It's a poor code, but please forgive me ...

code

You can use a carriage return (\ r) to override the terminal output. For example, if you want to create an animation where the hyphen - moves to the right every 0.5 seconds, the code would look like this:

sample.py


import time

    for i in range(0, 9):
        print('\r{0} {1}%'.format(' ' * i, '-'), end='')
        time.sleep(0.5)

If this is the case, if you go to the right 10 times, the program will end, so while `NOW LOADING` loops, After moving to the right to some extent, it gradually disappeared so that it could foam from the left. ↓

move.py


import time
import os

def main():
    #Setting the initial value for looping
    num = 1
    #Clock setting
    clock = 0.5
    os.system('cls')
    print(" ")

    #Code that moves characters from here
    while num != 0:
        str = 'N O W  L O A D I N G'
        space = ' ' * num
        count = num - 20

        if num < 20:
            time.sleep(clock)
            #The depiction part of the character. Moves sideways as the value of num increases
            print('\r{0} {1}'.format(space, str), end='')
            num += 1

        else:
            #After moving 20 full-width spaces to the right, go out to the right and in from the left
            if count <= len(str):
                time.sleep(clock)
                print('\r{0} {1} {2}'.format(str[len(str) - count:], ' ' * (num - count), str[:(le`n(str) - count)]), end='')
                num += 1

            else:
                num = 1

if __name__ == "__main__":
    main()

What can it be used for?

I don't think it will be a useful program, but with the package installer I believe it's fashionable if the letters ʻINSTALLING` move.

I wish I could move the original characters and ASCII art during the installation of ʻaptoryum`! I think.

bonus

I was originally planning to make the following code for fish to swim ...

Sunfish swims on a small LCD on a CD player while in a friend's car There is a mode, and I thought it would be nice, so I made it myself. However, I think that the code is not so cool, and the fish unexpectedly I couldn't display it cutely, so I posted it as a bonus ... Mi ((((°>>>)

fish.py


import time
import os

def main():
    #Setting the initial value for looping
    num = 1
    #Clock setting
    clock = float(input('Please enter the speed([early]1>>>5>>>10[slow])')) / 10
    os.system('cls')
    print(" ")

    #Fish swim from here
    while num != 0:
        if num < 11:
            time.sleep(clock)
            space = ' ' * num
            #The part of the depiction of the fish. Moves sideways as the value of num increases
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '  ', '△\n', space, 'Mi((((°>\n', space + ' ', 'Re' + '\033[2A'), end='')
            num += 1

            #Part for moving fins
            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '  ', '△\n', space, 'Ξ((((°>\n', space + ' ', 'Re' + '\033[2A'), end='')


        else:
            #After moving 10 full-width spaces to the right, the part that fades out to the right
            time.sleep(clock)
            space = ' ' * num
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '   ', '△\n', space, 'Mi((((  \n', space + '  ', 'Re' + '\033[2A'), end='')
            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '   ', '△\n', space, ' Ξ((((  \n', space + '  ', 'Re' + '\033[2A'), end='')

            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '    ', '\n', space, 'Mi((   \n', space + '   ', '' + '\033[2A'), end='')
            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '    ', '\n', space, '  Ξ((   \n', space + '   ', '' + '\033[2A'), end='')

            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format(space + '     ', '\n', space, '     \n', space + '   ', '' + '\033[2A'), end='')

            #If you fade out to the right, the part that fades in from the left
            time.sleep(clock * 2)
            space = ' ' * 20
            print('\r{0} {1} {2} {3} {4} {5}'.format(space , '\n', '°>', space + '\n', space, '\033[2A'), end='')
            time.sleep(clock * 2)
            print('\r{0} {1} {2} {3} {4} {5}'.format(' △', space + '\n', '(((°>', space + '\n', space, '\033[2A'), end='')
            time.sleep(clock * 2)
            print('\r{0} {1} {2} {3} {4} {5}'.format('  △', space + '\n', 'Ξ((((°>', space + '\n Les' , space , '\033[2A'), end='')
            time.sleep(clock)
            print('\r{0} {1} {2} {3} {4} {5}'.format('  △', space + '\n', 'Mi((((°>', space + '\n Les' , space , '\033[2A'), end='')
            num = 1

if __name__ == "__main__":
    main()

If you like, please copy and move it!

Recommended Posts

I made something with python that NOW LOADING moves from left to right on the terminal
Life game with Python [I made it] (on the terminal & Tkinter)
I tried changing the python script from 2.7.11 to 3.6.0 on windows10
I made a program to collect images in tweets that I liked on twitter with Python
I tried to summarize the languages that beginners should learn from now on by purpose
[Python + heroku] From the state without Python to displaying something on heroku (Part 1)
[Python + heroku] From the state without Python to displaying something on heroku (Part 2)
How to deal with the problem that the current directory moves when Python is executed from Atom
I made something that moves (wider range)
[Python] I tried to visualize the night on the Galactic Railroad with WordCloud!
I made a simple timer that can be started from the terminal
I tried with the top 100 PyPI packages> I tried to graph the packages installed on Python
Introduction to Python with Atom (on the way)
[IBM Cloud] I tried to access the Db2 on Cloud table from Cloud Funtions (python)
A story that I was addicted to when I made SFTP communication with python
I tried to make the weather forecast on the official line by referring to the weather forecast bot of "Dialogue system made with python".
I tried to touch the CSV file with Python
[Python] I made a system to introduce "recipes I really want" from the recipe site!
I wanted to use the Python library from MATLAB
I made a Python3 environment on Ubuntu with direnv.
I want to inherit to the back with python dataclass
I want to AWS Lambda with Python on Mac!
A memo that I touched the Datastore with python
I raised the Python version from 2 to 3, but every time I restart the ubuntu terminal, the version remains 2.
I tried to solve the problem with Python Vol.1
I felt that I ported the Python code to C ++ 98.
Try to create a waveform (audio spectrum) that moves according to the sound with python
When writing to a csv file with python, a story that I made a mistake and did not meet the delivery date
How to deal with the phenomenon that Python (Jupyter notebook) executed on WSL becomes Aborted
I made a server with Python socket and ssl and tried to access it from a browser
I tried to make a generator that generates a C # container class from CSV with Python
How to know the number of GPUs from python ~ Notes on using multiprocessing with pytorch ~
I tried to find the entropy of the image with python
[Python] I started Poetry & Impression that I moved from Pipenv to poetry
I tried to simulate how the infection spreads with Python
I tried using the Python library from Ruby with PyCall
I wanted to solve the Panasonic Programming Contest 2020 with Python
I made a package to filter time series with python
What I did to welcome the Python2 EOL with confidence
[Python] I want to use the -h option with argparse
Save images on the web to Drive with Python (Colab)
I tried to divide the file into folders with Python
I made blackjack with python!
I tweeted from the terminal!
I made blackjack with Python.
I made wordcloud with Python.
I want to extract an arbitrary URL from the character string of the html source with python
I made a garbled generator that encodes favorite sentences from UTF-8 to Shift-JIS (cp932) in Python
[Python] I tried to make a simple program that works on the command line using argparse.
A story that didn't work when I tried to log in with the Python requests module
About the error I encountered when trying to use Adafruit_DHT from Python on a Raspberry Pi
I made a library to easily read config files with Python
I tried to solve the ant book beginner's edition with python
Repeat with While. Scripts to Tweet and search from the terminal
I made a package that can compare morphological analyzers with Python
I want to use a wildcard that I want to shell with Python remove
I want to know the weather with LINE bot feat.Heroku + Python
[Python] A memo that I tried to get started with asyncio
I made a shuffle that can be reset (reverted) with Python
I tried to get started with Bitcoin Systre on the weekend
I read "Reinforcement Learning with Python: From Introduction to Practice" Chapter 1