Catch the Cat: A Simple Python Game
New cat in the house? Check.
Son interested in programming? Check.
Dad eager to learn more Python? Check.
Add it up and you get a little project the two of us worked up over a couple of nights this summer — a Python-based text game called Catch the Cat. You can download the code from its repository on Github. To use it, from a command prompt run:
The game’s simple: The cat’s on the loose in the house, and you have to catch it. Every time you move to a new room, the cat moves too — at random. To catch the cat, you both have to arrive in the same place.
OK, so we’re not going to unseat EA Sports here, but we met our goals: we had fun and learned some tricks. While I was using the exercise to help my son work through the logic choices required in game play, I got to add few things to my Python toolkit:
— Writing classes for the cat and player objects.
Have you written Python-based games? Suggestions for improvement here?