ID:160972
![]() Jul 4 2008, 7:30 am
|
|
How can you make it so in order to do a task in the game.(I.E. Training) you must push the correct arrow keys that show on the screen...if you mess up u stop or fail?
|
![]() Jul 4 2008, 7:48 am
|
|
override client/Move()
|
You program it in.
For example: var/points = 0 |
As Jemai1 said, you can catch what direction the client used through client/Move() (arrow pressed).
1. You have to have some sort of system to keep waiting for an input, which an infinite loop - or at least while()- should be used for. 2. When an input is detected, somehow get your running procedure to recognize the value entered. A variable containing the value pressed would be most useful. 3. When the loop recognizes that a value is entered, check if it is correct. If not, stop. If so, continue on (and maybe give a bonus). 4. After point #3 (after value obtained and checked) and somewhere before point #2 (before the next input wait), reset the recognition variable and randomly pick a direction (pick or even "1<<rand(0,3)" will do so) and reflect the chosen value to the arrow icon (which should be either an /image or a HUD object - set the dir of the arrow icon to the direction to make it easier on yourself). |
As you can see, his suggested loop isn't truly infinite (it only loops until an invalid input is given - he did accidentally say more along the lines of "until [any] input is given" in his latest post), though. In his code, you can see that he just moved the condition from instead of in the loop construct, to within the actual code itself (by using break), so the loop isn't infinite throughout the whole game session, it just continues to prompt the player until he gives invalid input and loses.
|
Let me rephrase that. A loop, infinite or not, that waits for a valid input is inappropriate to use.
Like what I've said, what the OP needs to do is override the client/Move(). Let me make my self clear. mob |
Jemai1 wrote:
Let me rephrase that. A loop, infinite or not, that waits for a valid input is inappropriate to use. Ah, I see, 'cause he wanted the input to be given through the arrow keys. I assumed GhostAnime got the concept right but you were criticizing the code implementation; my mistake. |