-1

I am trying to print ASCII art for my very simple game.

When I try to run the program, it just flashes for 0.01 seconds and disappears. I also tried to use a print statement for each new line.

turtle1 = (r'''\                         ___-------___
                                 _-~~             ~~-_
                             _-~                    /~-_
          /^\__/^\          /~  \                   /    \
         /|  O|| O|       /     \_______________/          \
        | |___||__|      /       /                \          \
        |          \    /      /                    \          \
        |   (_______) /______/                        \_________ \
        |         / /         \                      /             \
         \         \^\\         \                  /                 \     /
          \         ||           \______________/      _-_          //\__//
           \       ||------_-~~-_ ------------- \ --/~   ~\        || __/)
            ~-----||====/~      |==================|       |/~~~~~
             (_(__/  ./       /                   \_\      \.
                       (_(___/                       \_____)_)''')

If this is easily fixable and I'm stupid, I'm sorry. I'm just a beginner. ;)

This is my code (also available here):

import random
import os
import time
import sys

mageLvl = 1

def exit():
    sys.exit()


def refreshScreen():
    clear = lambda: os.system('cls')
    clear()


def titleScreen():
    print("  _ ___           _                  _    ___  _ ")
    print(" | |__ \         (_)                | |  |__ \| |")
    print(" | |  ) |_      ___ ______ _ _ __ __| |___  ) | |")
    print(" | | / /\ \ /\ / / |_  / _` | '__/ _` / __|/ /| |")
    print(" |_||_|  \ V  V /| |/ / (_| | | | (_| \__ \_| |_|")
    print(" (_)(_)   \_/\_/ |_/___\__,_|_|  \__,_|___(_) (_)")
    print("                                                 ")
    startOrExit = input("Start or exit? (y/n) ")
    if(startOrExit == "y"):
        refreshScreen()
        loading1()
    else:
        exit()
    refreshScreen()

def lvl1():
    print(turtle1)


def character():
    print("              _,._       ")
    print("  .||,       /_ _\\      ")
    print(" \.`',/      |'L'| |     ")
    print(" = ,. =      | -,| L     ")
    print(" / || \    ,-'\"/,'`.    ")
    print("   ||     ,'   `,,. `.   ")
    print("   ,|____,' , ,;' \| |   ")
    print("  (3|\    _/|/'   _| |   ")
    print("   ||/,-''  | >-'' _,\\  ")
    print("   ||'      ==\ ,-'  ,'  ")
    print("   ||       |  V \ ,|    ")
    print("   ||       |    |` |    ")
    print("   ||       |    |   \   ")
    print("   ||       |    \    \  ")
    print("   ||       |     |    \ ")
    print("   ||       |      \_,-' ")
    print("   ||       |___,,--')_\ ")
    print("   ||         |_|   ccc/ ")
    print("   ||        ccc/        ")
    print("   ||                    ")

turtle1 = (r'''\                         ___-------___
                                     _-~~             ~~-_
                                 _-~                    /~-_
              /^\__/^\          /~  \                   /    \
             /|  O|| O|       /     \_______________/          \
            | |___||__|      /       /                \          \
            |          \    /      /                    \          \
            |   (_______) /______/                        \_________ \
            |         / /         \                      /             \
             \         \^\\         \                  /                 \     /
              \         ||           \______________/      _-_          //\__//
               \       ||------_-~~-_ ------------- \ --/~   ~\        || __/)
                ~-----||====/~      |==================|       |/~~~~~
                 (_(__/  ./       /                   \_\      \.
                           (_(___/                       \_____)_)''')

def turtle():
        print("                             ___-------___                           ")
        print("                        _-~~             ~~-_                        ")
        print("                     _-~                    /~-_                     ")
        print("  /^\__/^\          /~  \                   /    \                   ")
        print(" /|  O|| O|       /     \_______________/          \                 ")
        print("| |___||__|      /       /                \          \               ")
        print("|          \    /      /                    \          \             ")
        print("|   (_______) /______/                        \_________ \           ")
        print("|         / /         \                      /             \         ")
        print(" \         \^\\         \                  /                 \     / ")
        print("  \         ||           \______________/      _-_          //\__//  ")
        print("   \       ||------_-~~-_ ------------- \ --/~   ~\        || __/)   ")
        print("    ~-----||====/~      |==================|       |/~~~~~           ")
        print("     (_(__/  ./       /                   \_\      \.                ")
        print("               (_(___/                       \_____)_)               ")

def charName():
    name = input("Enter your name: ")
    print("Hello there", name, "lvl", mageLvl,"young mage!")
    time.sleep(2)
    lvl1()

def loading1():
    for i in range(2):
        print("You are a young wizard with a passion towards your fathers craft... You want to become the best and beat everyone! Survive every tournament!")
        print("Loading.")
        time.sleep(0.7)
        print("Loading..")
        time.sleep(0.7)
        print("Loading...")
        refreshScreen()
    readyNo = input("Are you ready? (y/n): ")
    if(readyNo == "y" or "yes"):
        refreshScreen()
        charName()

name = "no one"

titleScreen()
Filip Š
  • 746
  • 2
  • 13
  • 22
Rollerino
  • 3
  • 3
  • 1
    *What* flashes and disappears? Please provide a [mcve] and the information of the system you are using and how you are running your code – UnholySheep Jan 05 '19 at 15:13
  • 1
    Provide the code you are using – PSM Jan 05 '19 at 15:14
  • 5
    At a guess - you're on Windows - you're double clicking your .py file in explorer, which your system associates with Python, it's running in a command prompt and then the command prompt immediately closes... – Jon Clements Jan 05 '19 at 15:16

2 Answers2

0

Given your code print_ascii_art.py

turtle = (r'''\                         ___-------___
                                 _-~~             ~~-_
                             _-~                    /~-_
          /^\__/^\          /~  \                   /    \
         /|  O|| O|       /     \_______________/          \
        | |___||__|      /       /                \          \
        |          \    /      /                    \          \
        |   (_______) /______/                        \_________ \
        |         / /         \                      /             \
         \         \^\\         \                  /                 \     /
          \         ||           \______________/      _-_          //\__//
           \       ||------_-~~-_ ------------- \ --/~   ~\        || __/)
            ~-----||====/~      |==================|       |/~~~~~
             (_(__/  ./       /                   \_\      \.
                       (_(___/                       \_____)_)''')

print(turtle)

Open a command prompt and navigate in the folder where the file of interest is.

Once you're in the right directory type:

python print_ascii_art.py

This should fix your problem.

NOTE: If you're willing to run your script by just double clicking on it, you should add the line input() at the end of your code. In this way the ascii art will be printed and the program will wait for any keyboard input before closing.

Employee
  • 3,109
  • 5
  • 31
  • 50
  • i was doing that lol. everything is fine except when it like prints it. it appears and disappears – Rollerino Jan 05 '19 at 15:20
  • You have to click on the gray check simbol on the top left of my answer in order to mark it as accepted. If you do it correctly, the check symbol should become green – Employee Jan 05 '19 at 15:26
  • Thanks for accepting the answer, now you know how to do it for future questions. Last thing: you can also choose to vote up the answer by clicking on the up arrow on the top left of the answer. – Employee Jan 05 '19 at 15:28
0

You forgot to indentate call to refreshScreen() in last line of function titleScreen() (from your code example). It refreshed screen before program exit which removed ASCII art.

This is corrected function titleScreen:

def titleScreen():
    print("  _ ___           _                  _    ___  _ ")
    print(" | |__ \         (_)                | |  |__ \| |")
    print(" | |  ) |_      ___ ______ _ _ __ __| |___  ) | |")
    print(" | | / /\ \ /\ / / |_  / _` | '__/ _` / __|/ /| |")
    print(" |_||_|  \ V  V /| |/ / (_| | | | (_| \__ \_| |_|")
    print(" (_)(_)   \_/\_/ |_/___\__,_|_|  \__,_|___(_) (_)")
    print("                                                 ")
    startOrExit = input("Start or exit? (y/n) ")
    if(startOrExit == "y"):
        refreshScreen()
        loading1()
    else:
        exit()
        refreshScreen()
Filip Š
  • 746
  • 2
  • 13
  • 22