Game Development Reference
In-Depth Information
9. Now add the following to the end of the End Step event code to add support for the
selectable text.
1: text_height = string_height_ext( text, 25, text_width );
2:
3: if( selectable = true )
4: {
5: if( mouse_x > vx+x && mouse_x < vx+x+text_width &&
6: mouse_y > vy+y && mouse_y < vy+y+text_height )
7: selected = true;
8: else
9: selected = false;
10: }
Notice how the string_height_ext function is used to find out how high the string of
text is, as the draw_text_ext function may have broken the text into many lines. The
rest of the code then just tests the mouse position against the “bounding box” of the
text in order to see whether the selected variable should be set or not.
Now run the game and check that it behaves as you would expect. If you have any problems,
then compare your version to the file dialogue2.gmk in the Chapter13/Games directory on the CD.
You should now see the spoken text displayed on the screen one word at a time, unless you
deliberately click through it. You should also be able to make selections at various points in the
dialogue that change the path of the conversation.
Hopefully, this provides a system that you will feel comfortable modifying for yourself. The
best way to create a new dialogue is to duplicate an existing one and change the states and text to
represent the conversation that is required. Remember that you can include all sorts of additional
code within the states to activate objects, or change other states in the game depending on the
outcome of different conversations. In this way, you can make sure that the dialogue really affects
the way that the game plays.
Congratulations
If you've managed to hold out this far, then it's definitely time to play the finished version of
Shadows on Deck , containing a vertical slice of game play with traps, puzzles, and dialogues. Load
shadows8.gmk from the Chapter13/Games directory on the CD and take some time to enjoy the
fruits of your labor by playing it all the way through (alternatively, you can run the shadows.exe
executable from the finished directory on the root of the CD). If you have any problem
completing the level, then refer back to the walkthrough provided earlier.
We hope that you find the finished level enjoyable, but we also expect that you can see plenty
of flaws and improvements that could be made, too. The point of producing a vertical slice is to
prove a concept has potential, but it is also the first opportunity for a designer to experience their
concept for real and see what is and isn't working about their design. At this stage in a game's
development, it is still possible to take quite drastic changes in direction: perhaps even changing
the core mechanics, or basic emphasis of the game.
There are certainly ways of improving the way the game is programmed, too. For example, a
better solution to the dialogue system would be to take a “data-driven” approach in which all the
text and flow of dialogues is stored in external data files rather than scripted in the code (see the
file dialog_alternative.gmk in the Chapter13/Games directory for a starting point on how you
might achieve this using arrays).
It is now up to you whether this concept will become a finished game, and what the form of
that game will look like. You are free to use the resources from Shadows on Deck in your own
Game Maker games, or even create new levels for the game based around our design. We only ask
that you share your games on the YoYoGames web site at http://www.yoyogames.com so that we
can enjoy what you have produced.
 
Search WWH ::




Custom Search