Computer Science Canada Remapping controls to be used with Input.KeyDown |
| Author: | Mongoose [ Sat May 27, 2006 8:01 pm ] | ||
| Post subject: | Remapping controls to be used with Input.KeyDown | ||
I'm making a pong game with some extra features such as items and remappable controls. The controls are easy enough to reset if I use the getch command, but the game runs better using Input.KeyDown (it isn't smooth when you hold down a key with the getch command). Is there any way to let Input.KeyDown recognize a key that is a variable? I tried:
where p1Up was a string (1) that you could set before. I get the error "Array subscript out of range". Is it not possible to do this sort of thing, or am I overlooking something stupid? I would appreciate any help or advice. |
|||
| Author: | MysticVegeta [ Sat May 27, 2006 8:06 pm ] | ||
| Post subject: | |||
Sure there is a way!!! Well you see, the argument for the Input.KeyDown array is either a char or "KEY_WHATEVER" (without the quotes) so there are various scenerios possible, for eg:
|
|||
| Author: | Cervantes [ Sat May 27, 2006 8:30 pm ] | ||
| Post subject: | |||
MysticVegeta: I think he knows that much. The point is not to hardcode the values for the keys, as you have done. Mongoose: You can use getch (or better yet, getchar) for that one section of the code only where you set the controls, then use Input.KeyDown for the rest of the program.
|
|||
| Author: | MysticVegeta [ Sat May 27, 2006 8:53 pm ] |
| Post subject: | |
If you read his post, he was using the type string(1) for p1Up which obviously doesnt work since string(1) not= char. His point from my opinion was that he was trying to pass a variable into Input.KeyDown |
|
| Author: | Mongoose [ Sat May 27, 2006 9:19 pm ] |
| Post subject: | |
Ah, excellent. It works. The problem was simple; the string (1)s needed to be chars, as you said. Thanks very much for the help guys, cripes that was quick. |
|