21.4 Making gamesThis is NOT the latest copy of this book; click here for the latest version.
As you have seen that PHP interacts smoothly with the console, it is particularly easy to make text-based games with PHP. However, thanks to the work of Brian Wang and Markus Fischer, you can even create graphical games with PHP. Naturally it is much easier to create text-based games, so that is where we will start.
The most popular type of text-based game is the adventure game, where all user input and feedback is given through textual descriptions. "GO NORTH", "GET AXE", "USE AXE ON MONSTER", etc. The nice thing about these games is that you can make them very simply, and strap on new features as you go - a famous example of this is NetHack, a text-based game for Unix that has been under development for two decades now and is still having new features added.
The game we're going to make will allow a person to navigate around a simple world and read the description of the places there. Once this is in place, you should be able to easily add the ability to pick up items, and let the player them in a selection of ways.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|