Computer Science Canada Simon Game, need help |
Author: | Fashoomp [ Tue May 22, 2007 3:35 pm ] | ||
Post subject: | Simon Game, need help | ||
ok, i have some code im working on for a simon game. Visually, its all there...but programming wise it is not. I have a randint from 1..4 to see which of the 4 buttons on the simon machine is pressed. It stops after 3 blinks (which i want). How can i get it to detect which arrow key is pressed (i dont want to use GUI). If i can assign up_arrow = 1, left = 2, etc... Here is what i have so far. Just comment out that pic, it just shows which arrow key corresponds with what colour...i think you can figure it out on your own...How can i put in a pause for it to wait for input (not Input.Pause), and still detect what i press?
|
Author: | Fashoomp [ Tue May 22, 2007 8:24 pm ] | ||
Post subject: | Re: Simon Game, need help | ||
Sorry to bug everyone, but i really need help, i made a bit more progress by assigning each arrow key a value. Now i just need to know how to make it stop and let me enter these arrow keys. Also, how to make it stop after 3 loops, and then every loop there after.
|
Author: | Albrecd [ Wed May 23, 2007 12:37 pm ] |
Post subject: | Re: Simon Game, need help |
First of all, you shouldn't declare the variable press inside the loop. Secondly, your code to check for the sequence pressed won't work because it only checks once for the pressed key, and then uses that variable for the entire sequence. Also, after the sequence, it doesn't give you enough time to press before it checks the variable and causes an error because it has no value. You should have an error-handling loop after it shows the sequence to determine if something has been pressed. If so, check to see if it's correct. If so, get the input for the next colour. If nothing's been pressed, check for input again until they press something. |