I’ve made an interactive fiction demake of Sierra’s graphical adventure game, Space Quest. It currently only features the first few rooms but demonstrates how the interactive fiction engine works.
IF.ino.hex (39.8 KB)
I developed a simple scripting language to make it easy to write IF games and it is designed to work in constrained memory environments like the Arduboy. Text is also compressed using a basic compression system that compresses string data to about 60-70% of their original size.
For the Space Quest demo:
Game logic: 979 bytes
String table: 4522 bytes
MicroIF engine: 8989 bytes
Total sketch size: 14490 bytes
Only used 50% of available flash so lots of space left!
Expand for an example of what the scripting language looks like
# An example script # Everything on the line after a # is a comment # All white space is ignored but can be used to make code easier to read # Variables are single bit flags that can either be true or false flag doorIsLocked is true # Items are things that can be collected and stored in the player's inventory to use later item key # The title and description attributes defines how the item is displayed in the inventory title "key" description "A shiny, copper coloured key." # This event is called when the item can otherwise not be used on use say "There is nowhere to use the key here." # Rooms are places where the player can visit. The first room defined is the starting room room kitchen title "The kitchen" # Attributes can have conditionals associated with them description when doorIsLocked "You are in the kitchen. It looks quite messy. The only door out of here is locked!" description when not doorIsLocked "You are in the kitchen. It looks quite messy. A door to the east is open." # Options are displayed to the player to choose from option "fridge" say "Nothing inside the fridge except a broken ketchup bottle." # Options can have conditionals option "east" when doorIsLocked say "The door is blocking your path." option "east" when not doorIsLocked go diningRoom # Conditionals can be based on item possession option "cupboard" when not have key say "Looking inside the cupboard you find a key." give key option "cupboard" when have key say "Nothing else in the cupboard worth taking." # Events for handling item usage on use key when doorIsLocked say "You unlock the door." unset doorIsLocked on use key when not doorIsLocked say "The door is already unlocked" room diningRoom title "The dining room" description "A long table with chairs. The kitchen is to the west." # You can assign events for entering a room on enter say "You just walked into the dining room!" option "west" go kitchen
The engine has been written in a way to distinctly separate the compiler, VM and front end so can be easily ported to other platforms. The way the game data is accessed is also abstracted so it would be very easy to store it on a flash chip for example.
More details on the engine and the source code available on GitHub:
Still to do:
- Save, restore and restart games