Thank you for visiting Blazing Games

Coding a Conversation

Mostly due to time constraints, I decided to break the conversation into separate rooms. When I think about this in hindsight, I realize that the algorithmic approach probably would have been just as quick to implement and would have greatly improved the ease of changing things. That is one reason I hope that readers take more time developing their projects then I do.

Coding the conversation can be broken into three separate things. First, the game states. Every part of the conversation has a constant tied to it so at any time I know where I am. This is handled in the initialization section of the code where constants that represent every room in the game are created. As the code just assigns numbers to variables, there is no point in putting that section of code here.

Next, when a conversation button is pressed, the dialog bubble code calls a function letting it know that an event has occurred. The event conveniently happens to be the next room to go to. So the dialog event handling function is simply a switch statement that moves the play-head to the appropriate room. This too is obvious code which I will not be showing here.

Finally, each room has to set up the actual text that gets show. This is very simple code that probably doesn’t need to be shown, but as this is the coding section of this chapter I will show you anyway so there is at least a snippet of code on this page. As you can see, the code simply assigns the text to be shown. The player’s choices are then set up, with the event code used being the next room to go to. That is all that is involved in creating a branching conversation.

Previous page
Chapter 3 Page 5

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2006 Blazing Games Inc. All Rights Reserved