Posts from 2010.

I am Boycotting Amazon for the Holidays

I wrote a book to teach kids and beginners computer programming by making games entitled, “Invent Your Own Computer Games with Python”. After a few months of distributing it online for free, I began to use the print-on-demand service at CreateSpace.com (owned by Amazon.com) to self-publish the book. I continue to make the book available for free online ( at http://inventwithpython.com ), but it was nice to receive a form of compensation I could buy burritos with.

CreateSpace.com continues to be a great service, and it makes it easy to publish on Amazon.com. But after Amazon.com has expelled WikiLeaks from its web hosting service, I have decided to pull my book from Amazon and boycott their site for the holiday season.

I encourage others to do the same.

Disabling the sale of Invent with Python

“Invent with Python” will probably still be for sale on Amazon via third party dealers with used copies, but I’ve instructed the CreateSpace.com to disable selling new copies of the book. I’ll continue to provide the full PDF online for free, because it’s always been more important to me to get it in the hands of readers than to make a buck off of it. (That, and dividing the not insignificant amount of money I’ll make from it by the very, very significant number of hours I put into it would be too depressing.)

In a way, this is an easy decision for me to make. I’m not dependent on book sales to provide me with a living, and boycotting Amazon.com for the holidays will only be an inconvenience. But this makes it all the more important that I don’t simply follow the easy path of silent complicity.

It will cost me over a grand this month to not sell my book, but it will cost Amazon (by my estimates) twice as much. In the end though, it probably hurts me more than it affects a multi-billion dollar company like Amazon. But I feel it’s the right thing to do, and that often doesn’t come cheap.

There are alternatives to the online giant, and I’ll be taking a look at Powell’s Books, Half-Price Books, Borders, Barnes and Noble, Biblio and others for gifts this year.

I understand that Amazon has a duty to its shareholders to protect its business interests and entangling itself with powerful political cronies does not help its bottom line. But this is why it is up to us to make defending freedom of speech one of its business interests. Amazon’s own claims that it pulled WikiLeaks for violation of its Terms of Services and not due to political pressure are equally lame and preposterous. We must vote with our voices and our pocketbooks, and I hope to set an example for others with my actions.

I’d like to thank Daniel Ellsberg (of the Pentagon Papers fame) for his call to boycott.

EDIT: Here's is an interesting and relevant link: Wikileaks Has Committed No Crime

EDIT (12/10): Damn it. I checked my createspace account this morning and found that even though I had the "extended distribution" (i.e. wholesale) channel disabled, they still sold 32 books to someone. I'll be donating the proceeds from that to WikiLeaks. I haven't seen any other sales aside from those.

Code Comments Tutorial: Tetromino

Welcome to the Code Comments Tutorial for Tetromino, a Tetris clone. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.

The text in between the triple-double-quotes are comments (technically they are multi-line strings, but Python uses them for multi-line comments). The Python interpreter ignores any text in between them, so we can add any comments about the source code without affecting the program. In general for Code Comments, the comments will describe the lines of code above the comment. It helps to view this file either on the Code Comments site or with a text editor that does "syntax highlighting", so that the comments appear in a separate color and are easier to distinguish from the code.

This Code Comments assumes you know some basic Python programming. If you are a beginner and would like to learn computer programming, there is a free book online called "Invent Your Own Computer Games with Python" at http://inventwithpython.com

The Code Comments programs make references to sections of this book throughout the program. This Code Comments can also teach you how to use the Pygame library to make your own games with graphics, animation, and sound. You can download Pygame from http://pygame.org and view its documentation.

You can make some easy modifications to the game by changing the all-caps constant variables (such as WINDOWWIDTH, FPS, BLOCKSIZE, etc.) This code uses global variables instead of object oriented programming in order to make it simple to understand.

Tetromino source code with comments.

tetrisb.mid background music. (required)

tetrisc.mid background music. (required)

More... »

Code Comments Tutorial: Snakey

Welcome to the Code Comments Tutorial for Snakey, a Nibbles clone. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.

The text in between the triple-double-quotes are comments (technically they are multi-line strings, but Python uses them for multi-line comments). The Python interpreter ignores any text in between them, so we can add any comments about the source code without affecting the program. In general for Code Comments, the comments will describe the lines of code above the comment. It helps to view this file either on the Code Comments site or with a text editor that does "syntax highlighting", so that the comments appear in a separate color and are easier to distinguish from the code.

This Code Comments assumes you know some basic Python programming. If you are a beginner and would like to learn computer programming, there is a free book online called "Invent Your Own Computer Games with Python" at http://inventwithpython.com

The Code Comments programs make references to sections of this book throughout the program. This Code Comments can also teach you how to use the Pygame library to make your own games with graphics, animation, and sound. You can download Pygame from http://pygame.org and view its documentation.

You can make some easy modifications to the game by changing the all-caps constant variables (such as WINDOWWIDTH, FPS, CELLSIZE, etc.) This code uses global variables instead of object oriented programming in order to make it simple to understand.

Snakey source code with comments.

More... »

Code Comments Tutorial: Slide Puzzle Game

Welcome to the Code Comments Tutorial for Slide Puzzle. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.

The text in between the triple-double-quotes are comments (technically they are multi-line strings, but Python uses them for multi-line comments). The Python interpreter ignores any text in between them, so we can add any comments about the source code without affecting the program. In general for Code Comments, the comments will describe the lines of code above the comment. It helps to view this file either on the Code Comments site or with a text editor that does "syntax highlighting", so that the comments appear in a separate color and are easier to distinguish from the code.

This Code Comments assumes you know some basic Python programming. If you are a beginner and would like to learn computer programming, there is a free book online called "Invent Your Own Computer Games with Python" at http://inventwithpython.com

The Code Comments programs make references to sections of this book throughout the program. This Code Comments can also teach you how to use the Pygame library to make your own games with graphics, animation, and sound. You can download Pygame from http://pygame.org and view its documentation.

You can make some easy modifications to the game by changing the all-caps constant variables (such as BGCOLOR, COLS, ROWS, TILESIZE, etc.) This code uses global variables instead of object oriented programming in order to make it simple to understand.

Slide Puzzle source code with comments.

More... »

Code Comments Tutorial: Simulate – A “Simon” Clone

Welcome to the Code Comments Tutorial for Simulate (A "Simon" clone.) Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.

The text in between the triple-double-quotes are comments (technically they are multi-line strings, but Python uses them for multi-line comments). The Python interpreter ignores any text in between them, so we can add any comments about the source code without affecting the program. In general for Code Comments, the comments will describe the lines of code above the comment. It helps to view this file either on the Code Comments site or with a text editor that does "syntax highlighting", so that the comments appear in a separate color and are easier to distinguish from the code.

This Code Comments assumes you know some basic Python programming. If you are a beginner and would like to learn computer programming, there is a free book online called "Invent Your Own Computer Games with Python" at http://inventwithpython.com

The Code Comments programs make references to sections of this book throughout the program. This Code Comments can also teach you how to use the Pygame library to make your own games with graphics, animation, and sound. You can download Pygame from http://pygame.org and view its documentation.

You can make some easy modifications to the game by changing the all-caps constant variables (such as BUTTONSIZE, FLASHSPEED, TIMEOUT, etc.) This code uses global variables instead of object oriented programming in order to make it simple to understand.

Simulate source code with comments.

More... »

Code Comments Tutorial: Memory Game

Welcome to the Code Comments Tutorial for Memory. Code Comments is a series of simple games with detailed comments in the source code, so you can see how the game works.

The text in between the triple-double-quotes are comments (technically they are multi-line strings, but Python uses them for multi-line comments). The Python interpreter ignores any text in between them, so we can add any comments about the source code without affecting the program. In general for Code Comments, the comments will describe the lines of code above the comment. It helps to view this file either on the Code Comments site or with a text editor that does "syntax highlighting", so that the comments appear in a separate color and are easier to distinguish from the code.

This Code Comments assumes you know some basic Python programming. If you are a beginner and would like to learn computer programming, there is a free book online called "Invent Your Own Computer Games with Python" at http://inventwithpython.com

The Code Comments programs make references to sections of this book throughout the program. This Code Comments can also teach you how to use the Pygame library to make your own games with graphics, animation, and sound. You can download Pygame from http://pygame.org and view its documentation.

You can make some easy modifications to the game by changing the all-caps constant variables (such as COLS, ROWS, BOXSIZE, etc.) This code uses global variables instead of object oriented programming in order to make it simple to understand.

Memory source code with comments.

More... »