Content Main Area Section
There are three files that make up the body of the text game engine. I will explain the purpose of each of these as a sort of introduction. After that, it's up to you to view the source files and figure out the rest.
Please contact me if you are thinking of implementing this engine for yourself. I would be happy to give you the source and get you started. I need to put some thought into attaching a license (such as GNU) to it so that I retain a copyright while still allowing everyone to use and modify it for free.
gameEngine.php
The gameEngine.php file contains the basic mechanics needed to
- read the querystring input submitted by the player
- parse the game state (transfered as a series of digits)
- get the game script results from gameParser.php
- perform the requested action and display the response text
gameParser.php
The gameParser.php file contains the meat of the engine. It reads the .gam script file for the game and translates the source into a structured object (from gameClasses.php) which can be manipulated by gameEngine.php. It must understand:
- variable declarations and assignments
- object declarations
- create special variables as needed
- action declarations
- if/else structures with test conditions
- code blocks enclosed in brackets
- text blocks, which can be combined
gameClasses.php
The gameClasses.php file contains classes for containing the game script objects, actions, and action blocks. The resultant objects created from these classes can perform their own if/else checks and return the correct results based on the scripted game logic. These classes are the meat of the game portion of the engine.
View gameClasses.php
A ConTEXT Highlighter File
My favorite Windows text editor is ConTEXT created by Eden Kirin. ConTEXT uses syntax highlighter files to perform syntax highlighting for tons of different languages. For fun, I created a highlighter file for my game script syntax. I used it in ConTEXT to export the highlighted source I show in The Iron Guppy Script page.
Download Game_File.chl

