Memory Game
watty09
Posts: 2
Can somebody give me a hand with solving this memory game. The idea of the game is like simon. User duplicates the sequence provided by the BS2 using pushbutton inputs. My code as posted, works for the first two LED's, Red and Green. I have no idea how to configure the other 2 led's in. I Can play the game using the red and green led's but as soon as the random generator, generates an led that is orange or yellow, i have to reset because i can't configure them in.
All help is appreciated!!!
Thanks
Ryan
All help is appreciated!!!
Thanks
Ryan
Comments
Also add some DEBUG so you can see the program flow. You may find out that RED is "generated" more often that others due to the if ... than evaluation of single bits. Take a look at SELECT and evaluating ranges of numbers instead.
I think you could replace some of the repetitious code with subroutines.
A minor suggestion - I did not see how "deep" your Simon sequence goes, but you may be able to "replace" the eeprom writes with just variable array.
Just a thought.
Your coding style is good, plenty of comments makes it easier to follow.
Vaclav
When you initialize the program, decide how many sequences "WIN" will be.... say 12 sequences and you've won.... so you dedicate twelve nibbles of data space to keep track of sequences. You'll need a pointer, to keep track of which sequence you're on and that's it!
so your data table will look something like this:
Sequence 0 / Data table position 0 = GREEN
Sequence 1 / Data table position 1 = RED
Sequence 2 / Data table position 2 = YELLOW
Sequence 3 / Data table position 3 = YELLOW
Sequence 4 / Data table position 4 = BLUE
Sequence 5 / Data table position 5 = GREEN
Sequence 6 / Data table position 6 = RED
......
If you dissect the code available in my signature, I used this exact thing in my project for Parallax. The code is well (I think) commented, so it should be easy to pick apart
Actually the green is not saved - you write 0 to eepromAddress.
In your Check_Response: subroutine you looking only for green and red colors in savedColor.
Orange and yellow are never checked for.
This is the logic
IF savedColor <> Green THEN ' If the values of savedColor
PbGreen = 0 ' and Green are different,
PAUSE 100 ' keep looping
ELSEIF savedColor <> Red THEN ' If the values of savedColor
youLose = 1 ' and Red are different, the
the savedColor here is either orange or yellow
RETURN
and you never get here !
this code does not get executed from here!
DEBUG "Here",cr
STOP
' player lost, return to main
ELSEIF savedColor = Red THEN ' If the values of savedColor
PbRed = 0 ' and Red are equal, keep
PAUSE 100 ' looping
ELSEIF savedColor = Green THEN ' If the values of savedColor
youLose = 1 ' and Red are equal, the
RETURN ' player lost, return to main
ENDIF
.