Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
Hey,

so I'm pretty much stuck at an event I'm trying to do. I want to have a little dance minigame. Basically arrow or spacebar pictures will be shown and if the player presses the corresponding key correctly, the player moves and you get 1 point. The big problem I have now, is that the button input doesn't work correctly, very unreliable. Sometimes when I press the right button, it registers it, but most of the time, it doesn't and I don't know why.

I have two variables that control the difficulty. One is Button Difficulty which is set at the beginning of the dance. It basically says how many buttons will be asked to press in total. So, every time a picture is shown, the variable counts down until it is at zero and then the game stops. The other variable is Fast Buttons. It can also be set at the beginning of the dance. It is responsible for how long the player has time to press a button until the next picture shows up. Basically I have a Button Timer variable that counts up and if it hits the same count of the Fast Button, your time is up.

Both work, I think.

Then I have a Press Button, which randomize between 5 settings: down, left, right, up, spacebar ©. So, the idea is that I have a loop in the minigame event. It loops through the Dancing common times as many times as the Button Difficulty. Every time it loops, it chooses one of the 5 settings at random. If the player presses the right button before the time runs out, the sprite should move a bit and the variable good dancemove counts up.

BUT - as I said, the input triggers only once every 10 times or something like that. I don't know why. Do I have too many things going on that the event has to cycle through?

Is the setting of my minigame event a problem (action button since it is an npc that starts the game). Should I switch the actual minigame over to a parallel processing?

If you want to help me out and tinker a bit with the problem, I have uploaded the game file.

https://dl.dropboxusercontent.com/u/1576581/Mini%20Games.exe

Little problem.. the thing is currently in german. I mean, the dialogues. Talk to the green-clothed guy in front of the stairs, choose the second option ("Tanzen"). It should transport you to the dancing area. Talk to the woman with the bunny ears to start the dancing. Every dance costs 5 gold. Talk to the old woman behind the counter to get 50 gold every time. You should start with 200 gold.

Thanks to everyone helping me out.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
Looks like you are checking for the input once every 10 frames and unless the player manages to hit the button at that exact moment, it won't get registered.
 
Last edited by a moderator:

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
Hmm, I changed the wait time to 1 frame and the fast button variable to 30. That works slightly better, but only slightly. It still only registers some button inputs and sometimes counts down so fast it immediately jumps to the next picture.
 

Rinobi

Veteran
Veteran
Joined
Mar 24, 2014
Messages
579
Reaction score
220
First Language
English
Primarily Uses
RMVXA
Looks like you'll need to find an alternative to the Wait command. Your button inputs won't be processed during the wait frames within your current Common Event. You might want to make a second event with a Parallel Process trigger to keep track of how much time the player has for button inputs. Or perhaps make use of the Control Timer.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
I guess the problem is that you are using Input.trigger?. Try using press? instead. Or use the "Button ... is being pressed" condition, which effectively uses press?

/edit: You would have to check for wrong input, then, because that way you can simply hold all buttons down and win ^^
 
Last edited by a moderator:

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Alrighty, so I did some experimenting and got it to work by applying parallel processing and lavra's suggestion of using Input.pressed? rather than Input.trigger?

For parallel processing events, you can use "state" variables instead of loops to control what the code is doing at what time. So, the event will run over and over again, and do the following: during state 0, nothing happens; during state 1, the dance is being set up; during state 2, the next dance move is being set up; and during state 3, the game is waiting for input. For example, when the time is up for the dance move or you input the correct move (in state 3), the state is changed back to 2 to set up the next dance move. Also, the variable 'button timer' increments by 1 each time the loop runs as normal, but because there is no "wait time" in between loops, it goes up REALLY fast! So, I would set variable 'fast buttons' to something like 30 or 40 for normal difficulty :)

Here is the code for the modified common event. I made it work for only two buttons (down and left) for simplicity

1OZEDYh.png


Yeah, and using Input.pressed? makes it so that the game will recognize input when the button is being held down, making it more accurate

 

Ah, and the only problem with parallel processing is that the player can still move when the event is running, so you'd have to "force" the player to stop moving, which is why I put in that script "$player_dont_move = true", ehehe... :D

Here's the code for when you talk to the lady

12dHPxN.png


The switch 'TEST' sets the dance common event running and it begins in state 1

Sorry if I made it too confusing! This is a cool and complicated idea and it must have taken you a LOT of time to make it this far!
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
Thank you soo much for helping me out!

I didn't came up with the whole event code. I tried Thex Tutorial (http://forums.rpgmakerweb.com/index.php?/topic/8291-thex-animated-power-bar-button-masher/) and build from there.

It works better now and the input finally registers every time. I added something to the lady npc. A conditional branch that triggers when the button difficulty variable is at 0 (meaning the dance is over). Then I switch the dance switch off, let the player move again and tell him how good he was (tell the variable good dancemoves).

One problem I have. Now that the common event is set to parallel processing, the player moves all around in the place. I feel like the dance moves don't have enough time to get carried out. So he is still moving when the next button comes and he doesn't move back to the starting position. And if you have a lot of dance moves it results in the player getting stuck at the barriers of the danceroom or npcs.

Also, the player still can move instead of making a dance move and I have the problem ending the event properly. It always shows one picture.
 
Last edited by a moderator:

Ralpf

Veteran
Veteran
Joined
Jun 5, 2014
Messages
590
Reaction score
153
First Language
English
Thank you soo much for helping me out!

I didn't came up with the whole event code. I tried Thex Tutorial (http://forums.rpgmakerweb.com/index.php?/topic/8291-thex-animated-power-bar-button-masher/) and build from there.

It works better now and the input finally registers every time. I added something to the lady npc. A conditional branch that triggers when the button difficulty variable is at 0 (meaning the dance is over). Then I switch the dance switch off, let the player move again and tell him how good he was (tell the variable good dancemoves).

One problem I have. Now that the common event is set to parallel processing, the player moves all around in the place. I feel like the dance moves don't have enough time to get carried out. So he is still moving when the next button comes and he doesn't move back to the starting position. And if you have a lot of dance moves it results in the player getting stuck at the barriers of the danceroom or npcs.

Also, the player still can move instead of making a dance move and I have the problem ending the event properly. It always shows one picture.
I just made a very simple event to test this, and it works on my simple event, so hopefully it will work in your more complex one. All I did was at the top of the event set move route wait 60 frame and repeat, I attached a movement to one key and and that was the only key that would move the player.

It sounds like your event has probably changed quite a bit since the first post, so without an updated demo (or screen shots) it's hard to say if that solution will work.
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
I have updated the game file. It is the same link as the first one: https://dl.dropboxusercontent.com/u/1576581/Mini%20Games.exe

I have altered the common event like Maximus suggested. As I said, it works better now, but the movement routes keeps messing up the game. I put a 3 wait frame after every move route, but it still messes them up sometimes and it makes the game also somewhat easier. The other issue is that one last picture always remains and that I can move around instead of inputting the right button. I have the feeling that this is also the reason why the game messes up the move route. Because if I press the right button, once the player moves on its own and then on top of that the game forces a move route on you. Parallel process might not be the answer here.

So, there are still some kinks left here and there. Grateful for everyone who wants to try it out.
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
You should check for wrong input adn skip to the next move once an input, either right or wrong, is recognized. Otherwise the player can just hold all 5 buttons to get every move right. Also, this will probably fix your other problem, as "moving around" will be considered wrong input.
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
But I still have the problem that the player actually moves around. The script command doesn't seem to be working.
 

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Oops! I forgot to mention that the script I put in "$player_dont_move = true" doesn't exist! Sorry...  ;_;  

To make it work you have to do a bit of scripting as below.

Here is the original Game_Player class:

Nh9soYw.png


The "move_by_input" method checks for keyboard input and moves the player. However, it "returns" and doesn't check input if any of those statements in the first line are "true". You'll want to add the following to this line:

RrCOiI3.png


So now, if the "$player_dont_move" variable is set to "true", the player won't move when you press the arrow keys, no matter what the player does. The dollar sign preceding the name means that you can set "$player_dont_move" to "true" or "false" anywhere in the game just by typing it into  a script command. It's kind of like an override for controlling the player's movement. I use it a lot in minigames and parallel processing events.

Unfortunately, this requires you have the full version of VX Ace to modify the scripts... There might be a workaround, but I find this the most direct and dynamic way   :)  although it is also a bit unconventional, as it directly edits the original code without external scripts.
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,812
Reaction score
889
First Language
German
Primarily Uses
RMMZ
The dollar sign also means, that if you go to title while this object is set and load/start a game, you won't be able to move, since it persists as long as the game is running.

You should set a switch instead.

Also, i'd rather not modify the base scripts. Add this script instead.

class Game_Player < Game_Character     alias :original_move_by_input :move_by_input     def move_by_input        return if $game_switches[1]        original_move_by_input    end end
This skips movement, as long as switch #1 is set.
 

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Yeah, lavra's method is definitely a safer and more prudent way to do it, haha!  :)  I would recommend following his advice :D
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
Yes, that helped! Awsome, thanks. :)

I also solved the problem with the last picture remaining. I moved the button difficulty +=1 part from state 2 to state 3. Before that it cut off the last dance move.

Now I have to adjust the difficulty/speed a bit, the wrong button input part and the winning conditions, but the rest seems to work perfectly now!

When all is finished, I will post a new game version here for everyone who is interested. I think, with proper animation and maybe bigger/better button pictures etc. you could have a nice minigame here. Right now, it looks more like riverdance or something like that, oh well.. :D

Certainly something to expand upon.
 
Last edited by a moderator:

Maximus32

Absolute Genius
Veteran
Joined
Feb 20, 2014
Messages
81
Reaction score
27
First Language
English
Primarily Uses
N/A
Glad we could help!
 

Candacis

Pixel Pusher
Restaff
Joined
May 2, 2012
Messages
1,719
Reaction score
2,709
First Language
German
Primarily Uses
Last edited by a moderator:

Latest Threads

Latest Posts

Latest Profile Posts

After the initial success with one event, I set up four different events on the same map to detect who is in which slot in my current party, and fortunately it managed to work as intended, with the events changing image to match the party members even as I swapped their positions around in formation. This will be a great tool for immersive scene design.
Finally finished the first hand-drawn map! It took me a week, but I'm so proud!
Actual line of code I just had to write for a plugin:

return Object.keys(this._shopStock).map(key => key.split(",")).map(element => element.map(value => Number(value))).filter(key => key[0] === mapId && key[1] === eventId);

Forum statistics

Threads
118,447
Messages
1,116,060
Members
155,420
Latest member
catboyfirsttimer
Top