Note About This Book: Advanced Lingo For Games was written by Gary Rosenzweig in 2000 for users of Macromedia Director 7. It is presented here for free on an as-is basis, with no updating. Most of the information and code here can be used in the most recent version of Director. The book has been reproduced from the final editing files archived in 2000, and not the final proof galleys. So some minor differences between this version and the printed version my exist. The entire contents of this book are Copyright 2000, Gary Rosenzweig. No part may be reproduced or copied without written permission. The text here is provided for individual use only.
Want to thank me for making this book available for free? Just buy Special Edition Using Macromedia Director MX and we'll call it even!

Advanced Lingo For Games
by Gary Rosenzweig


Chapter 14 Section 2

Game Overview

The cryptogram screen should consist of two overlapping text members. The first member displays the encoded message and never changes throughout the game. The second text member changes as the player guesses which letter matches which. Figure 14.1 shows the game screen with a game in progress.

Figure 14.1
The cryptogram game is shown here in progress. On a color screen, the higher letters are in red, the lower letters are in black.

A third element on the Stage is the cursor. This is seen in Figure 14.1 over the first lower letter. It's a simple bitmap box member that uses the "reverse" ink to highlight the letter underneath it. The user can move this cursor and then use the keyboard to guess which letter matches which.

Encoding the Phrase

The message is a line of text that consists of letters, spaces, and some punctuation. We need to encode the letters and leave the rest alone.

To encode the letters, you randomly assign another letter to represent every letter. For instance, "G" can represent "A." This means that every place "A" is present in the message, the letter "G" is used in the encoded message instead.

The one catch is that we do not want to have a letter represent itself. So, if it happens that "A" is randomly picked to represent "A," you should encode the message again rather than leave it like that.

The encoding is done by starting with a list of the 26 letters of the alphabet. Then, each letter is assigned another letter as its encoded translation. The result is a property list that matches real letters to encoded ones.

After this translation list has been built, the phrase is translated into its encoded form and stored in a property variable. It is also displayed on the screen.

Displaying the Solution

Overlaid on top of the encoded message on the screen is another text member. This text member starts off containing underscore characters in place of letters. As the player guesses which letters go where, the underscores are replaced with letters.

As the player gets closer to solving the puzzle, this text member begins to resemble the solution.

Why not use spaces to represent blank letters rather than underscores? A space is used by the text member as a possible location of a line wrap. This could mean that the solution text member could wrap in different places than the encoded text member, and the two text members will no longer line up. If you really want to use blank spaces rather than underscores, you may want to think about using the color property of text to color the underscores white, rather than black, thus making them invisible onscreen.

The Text Cursor

The interface needs to make it clear which letter the player is concentrating on. To do this, a small rectangular bitmap is used as a text cursor. It is placed on top of the text members on the Stage, and is set to use "reverse" ink. This has the effect of inverting the letter underneath it as shown previously in Figure 14.1.

This cursor needs to move during the game to point to which letter the player is concentrating on. We will provide two ways to do this. The first will be to allow the user to click on a letter and have the cursor move there. The second way will be to allow the player to use the arrow keys to move the cursor forward or backward in the phrase.

Phrase Storage

The phrase itself has to be stored somewhere in the movie to be used by the game. We could have it hard-coded in the behavior, or use on getPropertyDescriptionList to allow an author to set the phrase for each frame. However, both of these methods assume that we only want to use one phrase per game.

For this game, we'll store the phrase in a text member. As a matter of fact, we'll store many phrases in the text member. Instead of the game using only one phrase, it will present a series of phrases in either sequential or random order. These phrases will be stored, one per line, in a single text member.

At the start of the game, all these phrases are read into a list. If the game is to use them in order, it chooses the first phrase first, and removes it from the list. Then, when the player solves this phrase, the gameasks for the next phrase.

In the case where the phrases are to be used in random order, a random phrase is chosen from the list, and then used and removed from the list. This happens until there are no more phrases left.

Capital Letters

In cryptograms, the distinction between uppercase and lowercase letters becomes problematic for both the puzzle maker and the puzzle solver. As a result, the phrase is usually presented in all uppercase, and no lowercase letters are used.

However, to help the person making the phrase list, whether that is you are someone else, we will allow the phrases to be in mixed case. Before the program uses the list of phrases, however, it will convert all the text to uppercase. So, by the time the phrases are used in the game, they are guaranteed to be all capital letters.

Likewise, we won't need to ask the player to use only capital letters. As a player presses keys on the keyboard to enter letters, these letters are converted to uppercase before being used in the game.

Special Effects

In this game, sounds are strictly optional. I have included no sounds, nor hooks for them, in the example movie. However, you could certainly add puppetSound commands if you want.