6. DIALOG MESSAGES
messages, position, borders, colors




About messages

Dialog messages are used during gameplay, to present what the characters or the story teller has to say. They usually pause the game, display the text inside a bordered box and then wait for the player to hit the action key. After that, the dialog is closed and the game may resume.

Sometimes, more dialog messages are opened, one after another, presenting a conversation or more text than a single message could hold.

To see the simplest example of a dialog message, you just have to run the default template game, by launching the dizzy.exe application.

After a short loading screen, the game begins. Since the default template is just a starting point for your own projects, this is not much of a game. The player is spawned inside a very simple room and a greeting message is presented with the "HELLO WORLD!" text. Hit action key (ENTER) and the dialog will close, allowing you to move arround with the arrows keys.


The Message function

Let's see how this is done. Open the game.gs file from the data/scripts folder, into your favorite text editor and search for the "HELLO WORLD!" text. You will find it at the end of the BeginNewGame function, that is called each time a new game begins. It opens a dialog message using the Message function. Here is the default code:

Just for the fun of it, try to change the text a little, from "HELLO WORLD!" into
"HELLO EVERYONE!". Save the game.gs file and run the game again to see the difference.
This is as simple as it looks.

Message( x, y, text, textcolor, bordercolor )

This latent function pauses the game and opens a message dialog at the specified coordinates with the given text and colors. Then it waits latent for the user to press the action key. Because of this latent waiting, it can only be called from latent functions.

MessagePop()

This will close all opened dialog messages and resume the game. It's usually called after a Message function.

These functions are implemented in the messages.gs.

The dialog coordinates x,y give the position of the top left corner of the text area (not the border), relative to the room's corner. The coordinates are not expressed in pixels, but on a grid of 8x8 pixels cels. Inside it, the Message function will prevent the dialog's box from exiting outside the room's area, unless the text is too big for that to be possible.

The text can use the newline character /n to break the line and it should be given in UPPERCASE.

The colors of the text and borders are usually given in hexadecimal or using predefined integer values, as in the code displayed above, where the COLOR_MAGENTA defines the 0xffff00ff color (in the def.gs file).

Now, let's add a second dialog message, after the first one. Write the next code at the end of the BeginNewGame function.

Save and run. It will open another message, after you close the first one. As you can see, this one has a blue text and a red border, as the color values specifies. It's positioned at the top left corner of the room.


Try to comment the MessagePop call, the one after the first message and see what's happening.

The first message will no longer be closed when you press the action key, allowing the second message to be displayed on the screen in the same time. The last message pop will close both of them.

These are called cascade messages and they are common during some dialogs with characters in Dizzy games.


To make it easyer for the developer and to save him for specifying the colors for each message, a few other message functions with fixed colors are available.

Message0( x, y, text )
Story teller's message, white text and red borders.

Message1( x, y, text )
Player's messages, magenta text and green borders.

Message2( x, y, text, [text_color] )
Other characters' messages, white text by default and green borders.

You can edit them or add more in the messages.gs file.


BeginNewGame()

This latent callback is requested from the HandlerGameStart and it's called by a main menu function, each time a new game is started. It sets the player's position, plays an ingame music, starts an intro sequence or other similar things.


Homework

Play a little with dialog messages, open a few at different positions, different colors, to make sure you understand them well. Later in the book, we'll have another look into dialogs and see how they can be used as interactive menus.

To learn more about the dialog messages, read the reference chapters:
default template messages functions
default template dialogs functions
exported dialogs defines and functions.