Monday, 31 May 2021

Program a C# Text Adventure with Free Source Code

I’ve just published a major update to my adventure game system for C# programmers. To get the code, sign up to my newsletter and I’ll send you the download link:

The new BIFF C# (‘Bitwise Interactive Fiction Framework’) adventure game system now has the same feature-set as my Java framework (also available for free download). These frameworks are developed from the codebase created for my two books on text adventure programming, ‘The Little Book Of Adventure Game Programming in C# (and other languages)’ and ‘The Little Java Book of Adventure Game Programming’. 

New features in the C# version of BIFF include:

Adjective matching

Parsed adjectives are compared with an optional list of adjectives stored in Thing objects so there might be three small rings, say, brass, gold and silver. If the player enters "take small ring" the game will ask whether the "small gold ring", the "small brass ring" or the "small silver ring" is intended. 

Mass is associated with each object. 

Here mass can be thought of as the combination of size and weight so that the player can only carry items up to a certain total mass. The mass of items is calculated recursively when things are in other things (so player can't ‘cheat’ by placing high-mass items into a low-mass container and then carrying the container). 

The Thing hierarchy is extended 

Descendants include generic things (non-interactive scenery such as trees, walls, dust etc.) and lockable things. A lockable thing can be opened using a designated object (e.g. a specific key object). 

Other changes include:

Objects now have a Container property which stores a reference either to Room or to the container (such as a sack or chest) in which they are contained. Both the map and the list of treasures in the game are implemented as dictionaries. Special actions are now easier to implement (say, to take certain actions when the gold coin is put into the slot but not when the silver coin is put into the slot). You will find more documentation in the file NOTES.txt supplied with the code.

BIFF includes a simple sample game to get you started. The essentials of adventure game programming are explained in my two books on the subject:

The Little Book of Adventure Game Programming in C#

 Amazon (US) 

 Amazon (UK) 

 The Little Java Book of Adventure Game Programming

 Amazon (US) 

 Amazon (UK) 

Have fun!