I'm currently making an arcade-like system game with python. I separated my project into multiple files. gtn.py
is responsible for the "Guess the Number" game. startup.py
was supposedly used for first time startup such as ascii text main menu and game choosing. main.py
is for connecting in between the files.
Now the system is shortly explained like this. startup.py
starts, allowing player to choose their game, which only has 1 game atm, gtn.py
. This was the code for the game choosing
## startup.py# Startupclass Startup: print(tl.logo) tl.write("Welcome to the Arcade! Choose the game you want to play!\n") tl.delay(2) print("[1] Guess the number!") tl.delay(1) print("[2] Memory cards")# Startupclass StartUpProcess: def ChoosingStartup(): gamechoose = input("") if gamechoose == "1": tl.clean() game.gtnclass.gtngame()
The startup.py
file imports the gtn.py
surely, because they need the game from it.The code above called the gtngame()
function which is inside the gtnclass
class, which is inside the gtn.py
file. Now all the gameprocess works well, until you asked to return to the main menu.
Now the first time I tried importing the startup.py
and calling the ChoosingStartup()
function. But you probably guessed it gives circular import problem.
I tried several solutions including creating new function for both startup and game in __init__.py
file, didn't work either. If you want to see more detailed code, please refer to this repository inside the dev
branch