I'm working on a game in which a random letter is supposed to show up on the background. The player is then supposed to press that letter key. Upon pressing the key the letter is supposed to disappear, and be replaced by another random letter. This cycle has to continue until time runs out. Right now I'm using a separate sprite for each letter, and a random broadcast that sends a number (1-26) that corresponds to a letter. The problem is that I can't get the letters to disappear after the key is pressed, so they just pile up on top of each other. I realize that I might not be entirely clear on this, but I would really appreciate any advice.
Offline
how about one sprite with 26 costumes.
start the entire thing with a broadcast called next letter. (this can be triggered by the green flag)
you have a variable called 'letter' which you set to a random number from 1-26. then set costume to 'letter' (the variable)
then show
then the only solution i can think of at the moment is a list of ifs like this:
if letter=1 wait until key 'A' pressed,
hide
broadcast 'next letter'
if letter=2 wait until key 'B' pressed
hide
broadcast 'next letter'
etc
this starts the entire routine again.
im not sure if this is the best way but you may wish to try. i hope i have written it clearly enough.
goodluck
Offline
I agree with the notion of one sprite with multiple costumes.
I think that the responsive behavior is probably best done with 26 short scripts that look something like this:
when key 'a' clicked
if letter = 1
broadcast new-letter
One script can handle all the stuff for producing new letters (and keeping track of scores if you want):
when new-letter received
set letter to random 1 to 26
set costume to letter
Offline
Those ideas helped, and I think I'm on the right track, but there are still some major problems.
I'm confused by this part:
[blocks]<switch to costume[ <{ letter }> [/blocks]
How does it know which costume "letter" is corresponding to?
I can't get the costume to change after the correct letter is pressed, and I'm guessing that this is to blame.
Offline
Set the variable 'letter' to random 1 - 26 every time you want a new letter to come up.
e.g.:
<when I receive[ next letter
<set{ letter }to( <pick random( 1 )to( 26
<switch to costume[ <{ letter }>
Offline
Mick wrote:
Man, I LOVE these script images! They make explanining something soo much easier!
Congratulations, but there was really no need to post that separately.
Anyway, I'm still having trouble with my game. I'm getting really close though!
My current problem is that when I start the game, a letter will show up, but then it doesn't correspond to the correct key on the keyboard. The only way to tell which key to press is to go to the scripts and see which script is illuminated. Then, when you push the button it indicates (which is not the one on the screen), the letter on the screen changes to another one (good!), but then no key will work for it (bad!).
Any help on any of these issues will be appreciated.
Offline