Computer Science Canada Help on how to achieve clicking/user input using wheredotcolour and Mouse.Where |
Author: | unicorn-ellie [ Mon Jan 06, 2014 12:26 am ] | ||
Post subject: | Help on how to achieve clicking/user input using wheredotcolour and Mouse.Where | ||
Hi, ICS student here. Sorry if I'm posting too many times and it's annoying you. I followed np_123's suggestion of using whatdotcolour and mouse.where for user input for the Simon Says game but my code doesn't seem to work. In the game, the colours flash randomly and the user has to click on the colours in the right order. The user input should check that what the user clicks is correct, and if they get all of it right, they win. It should also make sure that if the user clicks something wrong, they will lose. In my code, even if you press the right colour, it still comes out as "you lose" and there are a few glitches. Is there a way to fix that? Also, if you could explain to me how to use whatdotcolour and Mouse.Where to achieve user input for this game, that would be great and very appreciated. Here is what I have coded and tried so far (Sorry, it's kind of long):
I know I kinda messed up/sorta don't know how to do it, but if you could just point out where I went wrong and tell me how to correct this so that the user input works properly that would be great. Thank you! P.S: For those of you who don't know Simon Says, here is the game:http://www.freegames.ws/games/kidsgames/simon/simon.htm |
Author: | np_123 [ Mon Jan 06, 2014 2:34 am ] |
Post subject: | RE:Help on how to achieve clicking/user input using wheredotcolour and Mouse.Where |
I've looked at your code briefly, what I think is the problem is that you have pattern (p) as a random integer from 0-8, using that to determine what square flashes However pattern (p) does not correspond with the colour of the square that flashes, so when you compare it to the value that whatdotcolour returns, it won't match for example -if pattern (p) = 1 then the brightred square flashes -whatdotcolour will return like 12 -pattern (p) not= whatdotcolour thus you lose If you want to compare elements in the array pattern to the result of whatdotcolour, you need the elements of your array to be initialized to the colour of the square that will flash, and then change that in your if statements |