Making games

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 learn PHP 7?

Hacking with PHP has been fully updated for PHP 7, and is now available as a downloadable PDF. Get over 1200 pages of hands-on PHP learning today!

If this was helpful, please take a moment to tell others about Hacking with PHP by tweeting about it!

Next chapter: Text-based world planning >>

Previous chapter: Graphical Interfaces Conclusion

Jump to:

 

Home: Table of Contents

Copyright ©2015 Paul Hudson. Follow me: @twostraws.