Posts by Al.

Gorilla.py: A Remake of Gorilla.bas

Source code: gorilla.py

An entire generation of people remember the Gorilla.BAS game that came with Qbasic, where gorillas on top of buildings threw exploding bananas at each other. This is a Python remake of that game using the Pygame game engine, and is fairly heavily commented so you can explore the source. To play the game in your browser, there is also a Flash version of Gorilla.BAS.

My prime motivation behind creating this was to compare how much easier programming is today compared to a decade ago with Qbasic. Python makes a great first language to learn, and I have argued before how Python is the New BASIC. (The second motivation was to promote my (free) book on Python games and get people back into programming. :) )

To demonstrate: not counting blank lines and comments (and the multiline strings for the graphics), Qbasic’s gorillas.bas is 784 lines of code while Python’s gorillas.py is 544 lines of code (about 30% less code!) Every programmer’s mileage may vary, but I think that makes a good case for Python’s syntax being expressive and simple.

This game was written by the author of “Invent Your Own Computer Games with Python”, a free book available under a Creative Commons license at http://inventwithpython.com. The book teaches Python to kid and adult beginners by giving the source code to several different games (along the lines of gorilla.py) and explaining them line by line. Learning to program this way is fun!

A print copy of the book is available (with free shipping) on Amazon.com for $25.

Attitudes on Programming for Kids: “They Need Blood Exploding Onto Their Faces Just to Keep Them From Yawning”

Wrote a new blog post on our attitudes towards kids and programming on my Coffeeghost blog.

“Invent with Python” Available in Print on Amazon

Invent Your Own Computer Games with Python, 2nd Edition, is now available in print on Amazon.com:

Buy “Invent Your Own Computer Games with Python” on Amazon.com

Of course, the book will still be available online, in full, for free under a Creative Commons license. If you like the book, but don’t/can’t buy the print version, go to Amazon and put in a review.

I’m very excited about this. Thanks to all the readers and people who have emailed me. Thanks!

Printed book still being edited.

I’m currently doing a very slow and thorough read through of the book to weed out the last of the typos, errors, and ambiguous statements in the book. Currently I’m about 2/3 of the way through the book, so it may be another couple of weeks from now that the book will be available for sale in print.

Afterwards, I plan on adding more videos and online traces to the website. A forum is also in the works, as soon as  potential spam issues are worked out.

Of course, the book will remain free online now and after the book goes for sale.

“Invent with Python” printed book on the way!

I’ve received a proof copy of the book from CreateSpace.com a few weeks ago and have finished editing it. Now all that remains is redoing the layout, sending off for another proof copy, and then making sure everything is okay. If all goes well, hopefully the book will be for sale within the next four weeks. I’ll post more updates on this blog as they happen.

The book will remain online for free under a Creative Commons license.

New “Choose Your Own Adventure” Game

Having a “Choose Your Own Adventure” style game for readers to look at was suggested to me, so I quickly wrote one up. The code is designed to be very simple, despite its length. There is no accompanying chapter, but I do provide a short description page.

The source code:

http://inventwithpython.com/extra/dragon2.py

The description page:

http://inventwithpython.com/extra/dragon2.html

These links are also on the Extras page on the main site.

Version 9 of the PDF is Available

Version 9 of the PDF is available, which includes several typo corrections and a completed table of contents. Thanks to everyone who emailed in typos and mistakes that they spotted.

Link to latest PDF: http://inventwithpython.com/IYOCGwP_book1.pdf

New Appendices

I’ve added Appendix A – Differences between Python 2 and 3 and Appendix B – Statements, Functions, and Methods Reference to the book. Quite a few people who have emailed me seem to be confused that the programs are in Python 3 (except for the Pygame programs, which are in Python 2). There aren’t that many differences, and I’ve outlined them in Appendix A. Appendix B is a handy and quick guide to all the functions used in the book.

Lessons Learned from Writing a Technical Book to Teach Programming

From 2008 to 2009, I wrote a book called “Invent Your Own Computer Games with Python” ( http://inventwithpython.com ) which guides young adults and complete beginners through learning how to program in the Python language. I’ve just completed the second edition of the book, which has been an exhausting amount of work. Looking back over it, I realized that it could have been a much less exhausting experience if I had made some simple preparations.

I’ve decided to write up this post on the lessons learned and the best practices for writing a technical book that aims to teach programming. This post will help me organize my thoughts so that I’m more prepared for my own future writing, but the practical tips can help others who aspire to write a book as well. More… »

What’s new in the second edition?

I’d like to enumerate all the new stuff that went into the second edition of “Invent Your Own Computer Games with Python”.

First, the book itself features four new chapters that covers Pygame, a game library for Pygame that makes it easy to create programs with GUIs that display graphics, play sounds, and accept mouse input.

Second, the 2nd edition covers the newer Python 3 version.

Third, the new website (http://inventwithpython.com) has been updated with several new features. The online diff tool allows you to compare your code with the books, so you can tell immediately where you’ve made typos. The Python interpreter’s error messages can sometimes be very cryptic, especially to the beginner. Finding the source of these error messages can be tedious without the diff tool.

The website has a videos section, where the videos on the book’s YouTube page at http://www.youtube.com/user/inventwithpython. (Currently, there is only a video accompanying the Reversi chapter. However, a screencast tutorial that follows along with the book is planned.)

The web site also has an extra content section, where additional programs and chapters that were cut from the book are placed.

These sections will be expanded in the future as their contents are organized.