Finished the two main gamemodes and added a menu system

This commit is contained in:
Lyx committed 2025-03-21 17:01:20 +01:00
1 parent 767d49b6be
commit a69b711289
6 files changed
+189 -32

No files matched your search

+38 -2
View File
@@ -1,4 +1,40 @@
from functions import binarian
from alphabet import alphabet
from functions import unbinarian
from submenus import entoBin
from submenus import binToEn
from functions import clear
import readchar
print(binarian("I am making duolingo for binary"))
def main_menu():
options = ["Translate from English to Binarian", "Translate from Binarian to English", "Exit"]
selected = 0
while True:
clear()
print("Use arrow keys to navigate and Enter to select:\n")
for i, option in enumerate(options):
prefix = "> " if i == selected else " "
print(f"{prefix}{option}")
key = readchar.readkey()
if key == readchar.key.UP and selected > 0:
selected -= 1
elif key == readchar.key.DOWN and selected < len(options) - 1:
selected += 1
elif key == readchar.key.ENTER:
if options[selected] == "Exit":
print("Exiting...")
clear()
break
elif options[selected] == "Translate from English to Binarian":
entoBin()
elif option[selected == "Translate from Binarian to English"]:
binToEn()
else:
print(f"Selected: {options[selected]}")
input("Press Enter to return to menu...")
if __name__ == "__main__":
main_menu()