Back in November last year, my eldest son and I popped over to the Insomnia Gaming Festival in Telford to take part in a game jam organised by Global GameCraft. (Today I bumped into the source again on a USB stick).
The theme for the day was “The Last Assignment”. We decided to go with a text based adventure game loosely based on the Dirty Harry movie.
With just 7 hours on the clock we managed to put together quite a fun adventure game with ambient sound and graphics:
and picked up the prize for best storyline!
Given the time constraints I decided to build the dialogue as a simple state machine using coroutines. In this scenario C# was my go to language as it provides basic iterator block support and a first class goto statement.
By building the game dialogue as a simple state machine I was able test it from the start as a console app and later easily integrate it into a graphical environment.
Here’s the state machine for the rookie scene:
public static IEnumerable<State> Rookie()
{
yield return new State(
"One way or another this will be your last assignment.\r\n" +
"Just 2 weeks left on the force before you retire.\r\n" +
"Back at the police station",
"You get a black coffee and a donut",
"A chai latte and a cup cake") { Theme="70s reflective;bullpen"};
if (Choice.Taken == 2) goto imposter;
yield return new State(
"Your new partner introduces himself.",
"You give him a stern look",
"Ignore him") { Theme = "70s reflective;bullpen" };
yield return new State(
"\"Why do they call ya 'Dirty Harry'?\"",
"Make up your own mind kid",
"Turn up your eye brow"
) { Theme = "70s reflective;bullpen" };
yield break;
imposter:
Game.Ended = true;
yield return new State(
"You have been exposed as an imposter.\r\n" +
"Cops don't chai latte, keep it real!")
{ Theme = "end game mp3;bullpen" };
}
which looked like this:
If you fancy having a play, the source for the game as a console app is available here:
Have fun!