Ask coding questions

← Back to all posts
How do I make it so that there is a developer mode?
Jrb12

I was wondering if there was a way in Python to make it so if I pressed a button it would allow you to type in which section you wanted to go to in my game. For instance, if I had a section called BossFight(), I would want to be able to press 7 on my keyboard and it would say "Where would you want to go?" and I would type that section and it would play that section. Bit of a long shot but wondering if I could make it happen

Answered by Bookie0 [earned 5 cycles]
View Answer
Voters
Jrb12
Comments
hotnewtop
Bookie0

Well you could ask them which section, they type something, and based on what they type, call the function BossFight():

Is this what you wanted? :)

Jrb12

@Bookie0 That's perfect, but is there a way to call this input by pressing a key on your keyboard?

Bookie0

@Jrb12 sure, you can use getch():

Jrb12

@Bookie0 Thank you!

Bookie0

@Jrb12 no problem! mark as correct answer (if it helped :)?

Jrb12

So how exactly do I run this in code? So basically, how do I make it so the orange arrow appears? (i don't know if that's what it's called)

Bookie0

@Jrb12 well just add go = getch.getch() where you want the user to be able to change to dev mode. And by orange arrow, do you mean this?

You won't be able to make it appear, but you can copy paste it and add it in a print statement I guess.

Jrb12

@Bookie0 Thanks!

Bookie0

No problem! Glad it helped! :) @Jrb12

JamesGordon1

you could do a multithreading and have the other thread running getch and watching for 7 being pressed then interrupting the main program and then doing something like this: