The Simple Console Rocket Animation in Python

in #wherein4 years ago

I have implemented a C/C++ Rocket that launches a rocket in the console in this post: Simple C/C++ Rocket Animation. My sons recently start learning Python programming and I think it would be cool to make a Python rocket version:

Here we go:

# save this as rocket.py
from time import sleep

def printRocket():
    print(
"""
           _
          /^\\
          |-|
          | |
          |N|
          |A|
          |S|
          |A|
         /| |\\
        / | | \\
       |  | |  |
       `-\\"\\"\\"-`
""")
    
printRocket()

delay = 300
for i in range(60):
    print()
    sleep(delay/1000)
    delay = delay * 0.9

And here is how it looks like when you launch the rocket simulation by python3 rocket.py

https://helloacm.com/wp-content/uploads/2020/11/rocket-simulation-in-python.mp4

It is a very simple rocket launching code ever. We just wait and print empty lines (that pushes the rocket upward). The time interval between two blank line printing is shorter and shorter (multiplier by 0.9 because the rocket is accelerating faster and faster until it is fully into the sky then we can't see it anymore after 60 empty lines)

--EOF (The Ultimate Computing & Technology Blog) --

Reposted to ALGORITHMS, BLOCKCHAIN AND CLOUD

Follow me for topics of Algorithms, Blockchain and Cloud.
I am @justyy - a Steem Witness
https://steemyy.com

My contributions

Support me

If you like my work, please:

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 62890.35
ETH 2544.51
USDT 1.00
SBD 2.94