I am trying to make a mechanic where the player needs to rapidly press a key on the keyboard to continue the game, if they fail then it's game over. Anyone know how to do this?
Rapid Button Press?
RPG Maker MV SupportBasically a series of conditional branches with waits, switches and variables for controlling.
The conditional branch checks if a key is pressed, but then you'll have to check if it is released again before counting - that is where you need to use switches and different nested conditional branches.
The conditional branch checks if a key is pressed, but then you'll have to check if it is released again before counting - that is where you need to use switches and different nested conditional branches.
Is there a way to check specifically if a key has been released? Or would you just use a conditional branch to check if it's been pressed and then do stuff in the "Else" part of it?
No, that is why you need switches and a series of conditional branches.
A key has been released if it it not pressed now but was pressed previously (as stored in the switch)
A key has been released if it it not pressed now but was pressed previously (as stored in the switch)
To elaborate...something like this:
Adding a timer to it just requires another variable (and branches) to count & check how many times the loop has run. ^_^
I happen to have a worked example, timed and with picture prompts, over on the Steam Workshop if you're interested. It's for battle skill input, but a couple of them use a "button mash" approach (the actual events don't require any plugins, don't worry). It may be a bit over-complicated for this purpose but here's a link if you're interested: https://steamcommunity.com/sharedfiles/filedetails/?id=1287577261
Code:
◆Control Switches:#0001 ButtonDown = OFF
◆Control Variables:#0004 Input = 0
◆Loop
◆If:ButtonDown is ON
◆If:Button [OK] is pressed down
◆Comment:Nothing.
◆
:Else
◆Comment:Button was pressed and released!
◆Control Switches:#0001 ButtonDown = OFF
◆Control Variables:#0004 Input += 1
◆
:End
◆
:Else
◆If:Button [OK] is pressed down
◆Comment:Button is now pressed down!
◆Control Switches:#0001 ButtonDown = ON
◆
:End
◆
:End
◆If:Input = 10
◆Break Loop
◆
:Else
◆Wait:1 frame
◆
:End
◆
:Repeat Above
◆Text:None, Window, Bottom
: :You escaped! \.Congratulations!
I happen to have a worked example, timed and with picture prompts, over on the Steam Workshop if you're interested. It's for battle skill input, but a couple of them use a "button mash" approach (the actual events don't require any plugins, don't worry). It may be a bit over-complicated for this purpose but here's a link if you're interested: https://steamcommunity.com/sharedfiles/filedetails/?id=1287577261
@caethyril The link doesn't work anymore, can we find the example somewhere else?
@Dumango - ah, I took it down after the YEP terms of use changed.
I just put it back up, with a slight change: it no longer includes the Yanfly plugins. If you just want to check out the events, no problem! If you want to playtest, you can follow the instructions on the workshop page. 👋
Since the OP of this thread doesn't seem to have logged in for over 5 years...
I just put it back up, with a slight change: it no longer includes the Yanfly plugins. If you just want to check out the events, no problem! If you want to playtest, you can follow the instructions on the workshop page. 👋
Since the OP of this thread doesn't seem to have logged in for over 5 years...
Closing this.
Original thread: https://forums.rpgmakerweb.com/threads/rapid-button-press.98121/