I want the smoke at the top to move infinitely. I am looking for a simple implementation. Here is my code:
def welcome():
print(" (")
print(" )")
print(" (")
print(" _)")
print(" __________| |____")
print(" / \\")
print(" / Welcome to \\")
print(" / A Horror Game \\")
print(" | By: A.D & T.P |")
print(" | ____ ___ |")
print(" | | | |___| |")
print("__|____|____|___________|__")
print("")
time.sleep(1)
Below a possible implementation without using any specialized package.
However, also look to these packages: curses and asciimatics.
See and play with this example in this online interpreter.
Here is an animated gif.
import time
import platform # Used by clear_screen
import subprocess # Used by clear_screen
# System independent clear screen function
# https://stackoverflow.com/questions/18937058/#42877403
def clear_screen():
command = "cls" if platform.system().lower()=="windows" else "clear"
return subprocess.call(command) == 0
def smoke():
# You could use the random package for a more realistic effect
# https://docs.python.org/3/library/random.html
shift = 15 + smoke.shift
print(" "*(shift+2)+"(")
print(" "*(shift )+")")
print(" "*(shift+2)+"(")
print(" "*(shift )+")")
# Next shift using current direction
smoke.shift += smoke.direction
# Change direction if out of limits
if smoke.shift>3 or smoke.shift<-2:
smoke.direction *= -1
def house():
print(" __________| |____")
print(" / \\")
print(" / Welcome to \\")
print(" / A Horror Game \\")
print(" | By: A.D & T.P |")
print(" | ____ ___ |")
print(" | | | |___| |")
print("__|____|____|___________|__")
print()
# MAIN CODE
smoke.shift = 0
smoke.direction = 1 # could be 1 or -1
# print('\033[2J') # One possible method to clear the screen
clear_screen()
# Infinite loop. Use CTR-C to stop
while True:
smoke()
house()
time.sleep(1)
clear_screen()
You'd probably want to do something simply such as create a while loop that calls upon multiple functions with print statements placing the smoke in different locations, e.g.:
def welcome2():
print(" (")
print(" )")
print(" (")
print(" _)")
print(" __________| |____")
print(" / \\")
print(" / Welcome to \\")
print(" / A Horror Game \\")
print(" | By: A.D & T.P |")
print(" | ____ ___ |")
print(" | | | |___| |")
print("__|____|____|___________|__")
print("")
time.sleep(1)
or something of the sort. If you call on multiple functions repeatedly it would appear as though smoke is "moving." I'm not exactly sure where you're calling this welcome function from though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With