Quote:
Originally Posted by Sharris
In this assignment I had to create a memory game where a sequence of buttons light up and the user has to press the buttons in that order. The only problem I am having with this project is how to have the level start over when the user selects the incorrect button and have the timer stop when they follow the sequence correctly. Here is what I have so far can anyone help me? Thanks.
|
I'm sorry but your project is not working as you think it is. I don't want to spend a lot of time on a detailed explanation but is important you understand what is there.
You have one method and five events, one of which calls the method.
In my first method you do the following
- Set all the button.button (the center of the button) to be invisible
- wait 5 seconds - This is a LONG time for a user to wait with nothing going on.
- Flash the buttons presumably in the order you want the user to copy.
- Start the timer
- Set all the button.buttons back to invisible - even though the step above turned off all the buttons it turned on.
- Cause each button to blink in order
- call Countdown on the timer again, even though it is not clear the last countdown has expired.
After "my first method" does all this, it never runs again.
Meanwhile, as long as the movie is running the other 4 events cause the button.button on the corresponding button to become visible. Whether it stays visible depends on the timing. If "my first method" is still running, the button.button will become invisible in steps 1,4,5 and possibly 2.
There is no logic to check if the user turns on a particular light and nothing to indicate the order in which the lights are turned on.
I know that the email medium can cause peoples comments to seem harsher than they are and so I want to stress I am trying to be constructive and hope you will take the above in that light.
As to what to do I would write separate methods for:
- Initialization of every thing.
- Initializing all the things needed for a round.
- Starting the play
- Checking the users input - this is called from an event when the user clicks on a button.
- Check for time-outs while the game is running.
- handle restarting or ending the game.
If you want to use the time but be able to randomly start and stop it you will have to modify the countdown method to allow for this. You could add a Boolean variable to the timer maybe called "active" to indicate whether the counter should be counting.
Hope all this helps,
Mark