minigame: realtime key press retrieval

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

minigame: realtime key press retrieval

#1 Post by Eatrentpie »

I've been mucking about trying to create some simple code to have some realtime keypress retrieval for a game/games I have in mind but I can't find any good examples. I can detect that an even has a occured but I can't get any further than that. HELP!!!

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: minigame: realtime key press retrieval

#2 Post by PyTom »

You need to explain in detail what you're trying to do.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

Re: minigame: realtime key press retrieval

#3 Post by Eatrentpie »

Ok I'll try and be more specific. I need to be able to access the status of keys that are currently held down or released. For the purpose of realtime interaction (NOT turn based or the like) I'm interested in monitoring specific keys probably the space bar and maybe the wasd keys. Accessing duration would be good but it's not the most important thing. any specific questions about my question?

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: minigame: realtime key press retrieval

#4 Post by PyTom »

There's two ways to do it. The best way is to use a creator-defined displayable, and look at the KEYDOWN and KEYUP events. That provides ordering information. You can also use pygame.key.get_pressed().
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

Re: minigame: realtime key press retrieval

#5 Post by Eatrentpie »

thanks I'll see if I can get it working either of those ways.
probably try the get key first

Eatrentpie
Newbie
Posts: 9
Joined: Fri Jan 02, 2015 6:41 am
Contact:

Re: minigame: realtime key press retrieval

#6 Post by Eatrentpie »

oh wait maybe not I already tried this method and the get key command caused a freeze

Post Reply

Who is online

Users browsing this forum: Bing [Bot]