[CENTER]Action Dependent Events
[SIZE=3]written by Sparkiness
Ever wanted to make your games more interactive?
[INDENT]In this tutorial, you will learn how to create a chest that relies on input actions in order to be opened. The tutorial will be taught as so: a screenshot will be shown, and underneath, an explanation will follow analyzing the events and what each performs.
[/INDENT][INDENT] First off, download the demonstration linked above, and give it a couple shots. Try pressing at faster/slower speeds on each attempt; do you notice a difference in the outcome?
[/INDENT][INDENT] Open the RPGXP Project
. We'll take a look at the first page of the chest event.
[/INDENT][INDENT] It starts off with two Show Text
commands which merely states the instructions. Since these do not necessarily effect the performance of the event as a whole, we'll take a look at the next one, Button Input Processing
. This command stores a variable with a set number when a key is pressed. We want the A key
, and only the A key
to effect whether or not the chest will open. So, we use that command, Button Input Processing
, to prepare for a button input (which we will set to the A key) later on.
The next command on the list is called Control Timer
. This begins a timer of a duration defined by the user; in this case, I set it to five (5) seconds.
After that, I created a Control Switches
command and made a switch called RepeatProcess
which I then set to ON
. This switch activates the second page of my chest event.
[LEFT]Notice I set the Trigger to Autorun: this was to prevent the player from moving out of place while the actions were being executed. Since the trigger was set to Autorun, the event will repeadly execute the command (there's only one on this page) in a continuous cycle. The desired effect here was to continuously prepare for a button input; thus the reason for a combination of an Autron trigger and a Button Input Processing event.
I also had, right next to the chest event, an invisible event. We'll take a look at that right now.
[LEFT]Take note that the trigger of this event was set to Parallel Process, meaning that it will begin once it's residing level finishes loading! It also, like the Autorun, repeadly executes the commands.
Let's take a look at the first Conditional Branch. This Conditional Branch is checking whether variable ButtonPress (this is the variable from the two previous Button Input Processing events) is equal to 14.
Here's a chart:
2 - DOWN, NUMPAD 2
4 - LEFT, NUMPAD 4
6 - RIGHT, NUMPAD 6
8 - UP, NUMPAD 8
11 - Z or shift
12 - X or ESC or NUMPAD 0
13 - C or ENTER or SPACEBAR
14 - A
15 - S
16 - D
17 - Q
18 - W
This is what the previous Button Input Processing events have been waiting for. Once a button has been pressed, it takes a look at the chart and stores a variable set to the number it is designated with. Thus, A is designated to 14.
In order words, the Conditional Branch is checking if A is being pressed. If it is being pressed, it will execute the commands within the branch. In this case, when A is being pressed, I made a sound effect play, made and increased a variable PressedAmount by 1 (this records how many times A has been pressed) and set variable ButtonPress to 0 to allow for further button input preparations.
Underneath this Conditional Branch, is yet another one. This time, however, checks if the timer we set earlier had already reached 00:00. If the timer has reached 00:00, we stop the timer and make a switch called ConfirmComplete which we then set to ON.
This switch deactivates the invisible event and activates the third page of our chest event.
[LEFT]This contains yet another Conditional Branch. Did you remember that when we pressed A, events were executed, one being the increase of a variable called PressedAmount? This conditional branch checks if PressedAmount has at least a value of 30. If it does, a switch is made and called SucessfulTry and set to ON. If it doesn't, all the events within the Else section are executed including, but not limited to, the reset of all variables and operations of all switches to allow the player another attempt to open the chest.
Also, the SucessfulTry switch we was recently switched to ON activates the fourth page of our chest event.
Here, the animation of the chest sucessfully opening is shown, music is played and variables and switches are reset. More importantly, Self Switch A
is turned ON
which activates the fifth page showing a static sprite of an open chest.
Have fun with this and remember you could also incorporate this into different events!
Thank you for reading!