i’ve got a secret

I said before Hangman is about lists. One of those lists is a list of blank letters that represent the word the player is trying to guess. The easiest way to deal with this is to write a custom block that generates a list of as many blanks as there are letters in the word.

In programming, there are always several right ways, however, there are usually many more wrong ones. Here is one idea of what that custom block to make a list of blanks might look like.

Someone could also build a word of blanks and then use this block from the Import Tools to turn it into a list.

However you build the custom block to make your list of blanks, to say three blanks the script would look like this:

In Hangman, the list of <length> blanks block would the beginning of my display word, before any letters were guessed. If the word were cat it would be three letters. Or run.

To code it, I’d make a variable to store that list. and then replace the blanks with letters as they were guessed correctly.The list variable would belong to all sprites so the host could do the work of checking it and the assistant could do the work of saying it.

Leave a Reply

Your email address will not be published. Required fields are marked *