Home
Help
Search
Calendar
Login
Register
Please
login
or
register
.
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Click here to join us on IRC (#charas on irc.freenode.net)!
Charas-Project
»
Game Creation
»
Requests
»
RPG Maker Programming
»
Key Inputs: A Dramatic Reading by Warxe PB
« previous
next »
Print
Pages: [
1
]
Author
Topic: Key Inputs: A Dramatic Reading by Warxe PB (Read 1840 times)
WarxePB
Action Sue
Royal
Posts: 3,601
What killed the dinosaurs?
Key Inputs: A Dramatic Reading by Warxe PB
«
on:
November 27, 2006, 04:21:38 AM »
Along with Switches, Variables and Branches, Key Input Processes (also known as Passwords) are a key component of coding in the RM2K/3 engine.
Part 1 - Getting Started
Key Inputs (as I'll be referring as them to) are considered an Intermediate-level command, which means that you'll probably want a degree of familiarity with RM2K/3. It's not necessary, but it certainly helps.
Anyways, some basic terminology:
Event
- An event is exactly what the name states - something that happens. Exactly what happens in an event is up to the user, making events a primary tool to move the story forward in an RM Project (game).
Event Commands
- This is a list of possible "commands" that you can put into an event. You can access this window by double-clicking on the <> symbol in an event.
The Event Commands window has 3 or 4 pages, depending on the version of RM you're using. I won't bother explaining them all - that's a job for another tutorial.
Command
- This is what any of the functions from the Event Commands window is called (for example, the first function, Message, is called a Message command). Commands are the driving force behind events, since without commands, events don't really have a use.
Part 2: Introduction to the Concept
A Key Input Process records keystrokes, and stores them in a variable. It is, in effect, a 'password'; you need to press the correct key, in order for the command to trigger and move on to other commands in the event. While rather simple in theory, these commands tend to confuse beginners, as there's several things that need to be done along with the Key Input to actually trigger another event.
Part 3: The Options
Let's start with a dissection of the command window. On Page 3 of the Event Commands window, click the seventh option on the left. You should get a window like so:
"Store Key Code in (Variable)": This is, of course, where the data collected is stored. Because you generally won't need more than 1 Key Input at a time, you can use the same variable multiple times. I like to call said variable "Input", but it's your choice.
"Option"
-Wait Until Key Pressed: If this option is selected, the event will wait for you to press a key before moving on; if it isn't, the code will continue onward, but it will still register any keystrokes. Most of the time, you're going to want to decheck this, but it does come in handy at some points.
-Store Amount of Time It Takes To Press Key In: Basically, if you check Wait Until Key Pressed, it will register (in 1/10s of a second) the amount of time it took for a player to press a key. Again, this is not used very often, but it is a nifty option to have.
"Keys To Process":
This sets the keys that the command will recognize. For example, if you only select Down (1), the command will only register when you press Down - pressing Left or Up or Enter does nothing. The numbers beside the keys is what's stored in the variable - for example, pressing Down will cause the engine to set the Input variable to 1. It's a bit confusing at first, but you'll get used to it.
Part 4: Applications
I'm going to give three examples, each demonstrating a feature of the Key Input.
Example 1: Reaction Time
(The Easy example)
So, your main characters are enjoying a carnival. One of them decides to do a reaction test, where the goal is to press a button when something pops up. This is the easiest way to use Key Inputs, and also uses the Time Storage function.
First, create a Wait of some arbitrary time (say 0.8 seconds). Turn a switch on which activates another event, or something. Next, create your Key Input. Both "Wait Until Key Pressed" and "Store Amount of Time..." should be checked, and the latter variable should be called TimeCheck or something. The only key allowed is Enter, so de-check everything else.
Next, display a Message. The message should say "Your reaction time is V[XXXX]", where the XXXX is the number of the variable you used for the Time Storage in the Key Input - if it was variable 0002, replace XXXX with 0002. Easy, eh? Well, it can be expanded upon quite a bit. Experiment a bit, and see what you come up with.
The code is
here
for your reference.
Example 2: Keypad
(The Medium example)
Your characters are infiltrating the enemy's high-tech fortress. In order to pass through a security system, you have to enter a series of keystrokes into a panel to open a door. This could be done with Input Number, but it's so much better with Key Inputs.
First, prompt the player with a "INPUT CODE" message. I'll assume that the code is somewhere in the fortress. For our example, the code is Up, Down, Left.
So, create a Key Input that recognizes the Up, Down and Left keys. Set the options to "Wait Until Key Pressed", but without the latter option.
Next, create a Conditional Branch. The parameters should be "Variable", "0001:Input", Number "4" (Up's number), and "Equal To". This means that it will only accept Up. In the Else Handler of this branch, play a Sound Effect of a buzzer, and do something (an encounter, perhaps). In the True handler (right above the Else handler), create another Key Input with the same options as the above, and another Branch, also with the same options but with number "1" instead of "4". This is the next part in the sequence: Down. The Else Handler should be the same as the first. Once again, do the same thing, but with 3 in the Number slot (Left). Once that is done, turn a switch on that opens the door.
The code should look like
so
.
Example 3: Dodging Bullets
(The Hard example)
So, let's say that you're making a Matrix fangame (*shrug*), and you're at the part in the first movie where Neo dodges Smith's bullets. So, we need our character to dodge a bullet, and it would be boring to just have him do it automatically - so let's use our newfound Key Input powers to let him do it. And, because we want to add some originality, we're going to make a timeframe where he can dodge - thus, if he doesn't dodge, he gets shot and dies, causing a Game Over. This can be done without the "Wait Until Key Pressed" options.
First, make the messages and whatnot that lead up to the dodging. I'm going to assume that there's none, and it's simply "lol I'm gonna shoot you Neo", then the event.
First, create a Loop/Cycle (eigth option in Page 3). In the Loop, create the Key Input command. Deselect "Wait Until Key Pressed", and deselect all but one key (I'll use Enter). After the Key Input , create a Conditional Branch/Fork Condition. The Branch/Fork's parameters should be set to "Variable", "0001:Input", Number "5" (Enter's value), and "Equal To". Right underneath, insert a "Break Cycle/Break Out of Loop" (it's right underneath Loop/Cycle in Event Commands), and continue on with the event underneath the "End Loop" there.
In the Else Handler of that Branch (if there isn't one, right-click the Branch and select Edit, then select the checkbox at the bottom), create a Wait of 0.1 seconds. After, create a Variable Operation that adds 1 to a variable called DodgeTime, and after that, create another Branch with the parameters "Variable", "0003:DodgeTime", Number "10", and "Equal To". In that Branch, the character is shot, so create a Game Over. Don't worry about the Else Handler; the section in the Loop will repeat itself until DodgeTime is 10 (in other words, 1 second has passed), and in that timeframe, the character can successfully dodge that bullet - but wait too long, and he dies.
Screenie
here
.
5. Outro
So, that's about it for Key Inputs. If you have any questions, go ahead and post them.
Until then, adieu!
Logged
Blog:
The Gigaverse
Twitter:
Initial Chaos
Print
Pages: [
1
]
« previous
next »
Charas-Project
»
Game Creation
»
Requests
»
RPG Maker Programming
»
Key Inputs: A Dramatic Reading by Warxe PB