How do I add a "cheat code"?
by Rob Nichols · in Torque Game Builder · 07/07/2013 (3:48 pm) · 1 replies
I'll try to be as clear as possible, (maybe that's why I'm not finding other threads like this) I'm making a 2D side scroller and I want to enable the player to 'enter' a cheat code in the middle of a level to unlock a bonus level.
As a nod to old console games I thought it'd be funny to use the old "up-up-down-down-left-right-left-right-A-B" entry. But I'm not sure how best to go about capturing the players 'entries'.
As I currently don't use the 'up' or 'down' keys for actual player movement, I thought about setting up a SceneObject that would acknowledge when the player entered. Then if while in that small SceneObject the player pressed 'up' it would pop the actionMap to prevent player movement and could evaluate the remaining player input.
If it was correct a chime would sound announcing that it was successful and push the actionMap again to re-enable player movement to finish the current level.
If a input entry was evaluated false to what was required, it might buzz to indicate it not entered correctly, push the actionMap, and maybe bounce the player up so they could try again if they choose once they land again.
The whole idea may be a bit over my head at this point, but is there a way to "capture" a string of movements to compare. I'm not sure about the actionMap pop... wouldn't that disconnect or disregard any input in those directions...?
Any thoughts would be extremely appreciated.
As a nod to old console games I thought it'd be funny to use the old "up-up-down-down-left-right-left-right-A-B" entry. But I'm not sure how best to go about capturing the players 'entries'.
As I currently don't use the 'up' or 'down' keys for actual player movement, I thought about setting up a SceneObject that would acknowledge when the player entered. Then if while in that small SceneObject the player pressed 'up' it would pop the actionMap to prevent player movement and could evaluate the remaining player input.
If it was correct a chime would sound announcing that it was successful and push the actionMap again to re-enable player movement to finish the current level.
If a input entry was evaluated false to what was required, it might buzz to indicate it not entered correctly, push the actionMap, and maybe bounce the player up so they could try again if they choose once they land again.
The whole idea may be a bit over my head at this point, but is there a way to "capture" a string of movements to compare. I'm not sure about the actionMap pop... wouldn't that disconnect or disregard any input in those directions...?
Any thoughts would be extremely appreciated.
About the author
Owner of Game Crossing Studios I've been a hobby game maker for a while and decided to jump in with both feet. Feel free to see what I'm up to: www.GameCrossingStudios.com
Orion the Hunter
Fritterflames
Then, each time you press a new key, it registers a new keyword. You should also make it so once the strlen reaches however many characters long the cheat code is, it checks to make sure $Variable = "UPUPDWDWLRLRAB";
If not, $variable is set back to "";
Also, make sure that you have a timer that resets $variable in two seconds so that if you mess up while trying the combo, it resets and lets you try again by clearing $variable. Every time you press one of the cheat-buttons, however, the timer is stalled and set back to 2 so you don't have to write the whole code in 2 seconds.
Sorry if it's confusing. I hope I helped!
~ Orion