Yeah. I have no idea why I decided to do this
Here is an example of this for my new pokemon adventures game:
def getinput(options):
global solution_get_input
solution_get_input = 0
selected = 0
stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
stdscr.keypad(True)
while True:
stdscr.clear()
for i, option in enumerate(options):
symbol = ">" if i == selected else " "
# Apply color, style, and bold to the text
if i == selected:
stdscr.addstr(i, 0, f"{symbol} {option}", curses.A_BOLD)
else:
stdscr.addstr(i, 0, f"{symbol} {option}", curses.A_BOLD)
key = stdscr.getch()
if key == curses.KEY_UP:
selected = (selected - 1) % len(options)
if selected == -1:
selected = (selected + 5) % len(options)
elif key == curses.KEY_DOWN:
selected = (selected + 1) % len(options)
if selected == 5:
selected = (selected - 5) % len(options)
elif key == ord('\n'):
if selected == 0:
solution_get_input = selected
pass
elif selected == 1:
solution_get_input = selected
elif selected == 2:
solution_get_input = selected
elif selected == 3:
solution_get_input = selected
elif selected == 4:
solution_get_input = selected
pass
# Add more elif statements for each option
break
curses.nocbreak()
stdscr.keypad(False)
curses.echo()
curses.endwin()
options = ['Your Pokémon','Your Pokédex','Travel','Catch Pokémon','Quit']
then, you can use an if statement. eg.
if solutions_get_input == 0:
pass ( add in your code )
... etc ( you get the point )
You will need to add your own elif statements for this if you expand your options.
literally I tried termios and it didnt seem to work.
termios stands for terminal operating system
which is exactly why its termi
and os