Today, we're going to make a game using the Doodle library for python. We'll be building snake, which has pretty simple rules. You're a snake, you like strawberries, you don't like eating yourself and the more you eat the more energy you, so you move faster. Here's what it should look like once we're done.

For this game we're going to need to install the following tools:

To install Doodle, just download "doodle.py" from the link above, and copy it into the same folder as your code. I'm also going to assume you know at least a little bit of python, there shouldn't be anything more complicated than arrays though!

Working with Doodle

So, now we've installed everything we need, we can start writing code. Doodle tries to stay out of your way, and just make it easy to get stuff done, so let's get started and create our first program with it, and we'll see what was going on afterwards. Run the following code below to see what it does.

from doodle import *

make_window(640, 480)

while True:
    fill("green")
    next_frame()

On our first line, we have from doodle import *. You need to put this at the top of any program running Doodle, it sets up everything we're going to need to use.

So now on line 3 we see our first real line of code. make_window(640, 480). On a computer, everything is measure in pixels - it's the number of dots on your screen big something is. We tell Doodle we want to make a new window to draw our game in, and that we want it to be 640 pixels across, and 480 pixels tall.