Jump to content
  • Advertisement
NeverSay

C# Enforcing input order?

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!