Enforcing input order?

Started by
2 comments, last by mager1794 6 years, 3 months ago

I'm new to coding and I'm trying to learn as I go along. I had an idea for a kind of speed input game, where a 3 arrow code randomly generates and then you need to complete it left to right.

I have figured out how to randomly generate the code, including the visual prompts but the issue I'm having now is figuring out how to enforce the left to right input I want. 

I'm guessing a massive part of it is all three image objects I use, use the same code. So then do I need to make separate codes for each one and then?..... and even still I'm having trouble figuring out how to actually do the enforcement of input order. 

Any suggestions?

Advertisement

How do you create the random code? Do you have any way of knowing what code it is? Or are they just images? In some way you will have to know what the code is, and in what order they are. From there on there are several simple ways of making sure the user clicks in order. I guess the simplest would be to keep the code in a collection of some sort, array, list. And then loop through that collection while the user inputs, is the input the correct one? Continue one index up and try the next one. This make is easy to add more to the code, as well as resetting if the user entered the wrong code, just reset the index.

If i understood it correctly.

You're going to need to build a controller that accepts ALL input, and compare it to the input you're expecting.

Create a class with two variables
Button
Completed

And then fill them into an array of x, make sure that youre code doesn't process the next button in line unless the value of completed on the previous is true.

This topic is closed to new replies.

Advertisement