Game Development Reference
In-Depth Information
Open up dialogue1.gmk from the Chapter13/Games directory on the CD and run the example.
Not much happens yet, but you should see a picture of the first prisoner's face and a blue
rectangle. This is where the spoken text will eventually appear, but first we'll take a quick
overview of what is already in place.
Exploring dialogue1.gmk
1.
There is a range of different sprite resources for the faces of different characters and a
mouse icon. There is nothing particularly special about these.
There is a font set up for you ( font_speak ) that includes all of the letters, numbers, and
special characters of the font you have selected. This will usually default back to Arial
unless you happen to have the same font installed as us. Feel free to choose something
more appropriate for the pirate theme, but make sure it is clear and readable.
2.
3.
There are four objects already created for you that form the basis of the dialogue
system. The obj_text object handles drawing a single sequence of text one word at a
time and selecting that text with the mouse. The obj_dialog object is the parent object
for all dialogues. Dialogue objects such as obj_dialogue_test store information about
all the different sequences of text in a complete dialogue, including the way in which
they branch. Finally, obj_controller simply exists to create two instances of the
obj_text object in its Create event at the start of the game. These are assigned to global
variables so that you can use the same instances to handle all the dialogue text in the
game. The positions of these instances are hard-coded so that the text will appear
within the blue rectangle at the bottom of the screen. Note that the coordinates are
specified relative to the top left corner of the view, rather than a position within the
room.
global.text1 = instance_create( 135, 500, obj_text );
global.text2 = instance_create( 135, 540, obj_text );
The dialogue object ( obj_dialog ) includes a number of different events that are
inherited by all dialogues, including the Create event, the Global Left Pressed mouse
event, the User Defined 0 event, and the Draw event. We'll explore these in turn next.
4.
5.
The Create event sets up a number of key variables that include the current sequence
of text being displayed ( sequence ), the next primary sequence of text ( next_sequence1 ),
and the next secondary sequence of text ( next_sequence2 ). These primary and
secondary sequences are used to create the branches in the dialogue. If there is only
one path for the dialogue, or the player has chosen the first option, then
next_sequence1 is used, but when the player chooses the second option, then
next_sequence2 is used. Finally, there is a variable that stores who is talking ( talking ),
which is simply used to decide which face is displayed adjacent to the text.
 
Search WWH ::




Custom Search