Source Code Makeover: Square Shooter, Part 3
Mon 13 August 2012 Al Sweigart
This is a continuation from Part 1 and Part 2, where I go through the source code of Square Shooter, an Asteroids clone, and try to redesign the code to be more readable.
Writings from the author of Automate the Boring Stuff.
Mon 13 August 2012 Al Sweigart
This is a continuation from Part 1 and Part 2, where I go through the source code of Square Shooter, an Asteroids clone, and try to redesign the code to be more readable.
Fri 10 August 2012 Al Sweigart
This is a continuation from Part 1, where I go through the source code of Square Shooter, an Asteroids clone, and try to redesign the code to be more readable.
Thu 09 August 2012 Al Sweigart
In this blog post, I'm taking a game off of Pygame.org and going through it to make it more readable and extend its functionality. You'll see an example of how to take code that works and changes to improve it's design (but more importantly, I explain why I make those changes).
Mon 30 July 2012 Al Sweigart
If you need an idea for a game, try this random game mechanic generator.
Wed 18 July 2012 Al Sweigart
Mon 09 July 2012 Al Sweigart
Figuring out what Python's error messages mean can be kind of tricky when you are first learning the language. Here's a list of common errors that result in runtime error messages which will crash your program.
Thu 21 June 2012 Al Sweigart
True is the opposite of false. Up is the opposite of down. What is the opposite of dog?
Wed 16 May 2012 Al Sweigart
Thu 03 May 2012 Al Sweigart
This post goes into the details of how you can add a "save game" feature to your Python games.
Fri 06 April 2012 Al Sweigart
To figure out bugs in your code, you might put in print
statements/print()
calls to display the value of variables. Don’t do this. Use the Python logging
module.
Sun 25 March 2012 Al Sweigart
I made a twitter bot that checks every hour for someone who has asked the question, “Why do homeless people have dogs?” and automatically replies, “Because a dog will love you even though you are homeless.”
Mon 19 March 2012 Al Sweigart
CircleMUD was a popular piece of server software for running a MUD, and it came with a sizeable virtual world (which the admin could modify/append to customize their fantasy world.) It would be pretty handy to use parts of this data if you were creating your own virtual world for a text adventure game, but the format of CircleMUD's data files is kind of obtuse and not amenable to manipulation.
So I wrote a few scripts to convert these files into a single XML file which is 4MB when unzipped. You can parse this file and modify it to suit your needs. It contains 1979 rooms across 30 different areas (called zones in the file), with 46 shops and 569 different "mobs" (mobile objects, which are the monsters and NPCs). There are 678 different types of objects, including 116 weapons and 154 types of armor.
Sun 18 March 2012 Al Sweigart
Math and programming have a somewhat misunderstood relationship. Many people think that you have to be good at math or made good grades in math class before you can even begin to learn programming. But how much math does a person need to know in order to program?
Sat 03 March 2012 Al Sweigart
They don’t want to learn how to program just for the sake of programming. They don’t want to learn about algorithm complexity or implicit casting. They want to make Super Mario or Twitter or Angry Birds.
Mon 20 February 2012 Al Sweigart
Fri 10 February 2012 Al Sweigart
I've completed my next book, which focuses on the Pygame library and making graphical games in Python.
Fri 09 December 2011 Al Sweigart
Download pyganim.py and example programs. (Works on both Python 2 and 3.)
Details at http://inventwithpython.com/pyganim/
Pyganim is a module that you can import into your Pygame games to handle sprite animation.
Tue 29 November 2011 Al Sweigart
IDLE is great, but over time I’ve noticed a lot of problems with IDLE that I wish someone would fix.
Fri 21 October 2011 Al Sweigart
Here are a couple games I wrote. The first was so popular that I made a sequel.
Fri 21 October 2011 Al Sweigart
Here's the introductory chapter to my next book on Python and Pygame. It assumes you have some Python and programming experience (if you don't, give a look to Invent with Python), and offers a quick view of all of the major parts of Pygame.