Code Comments Tutorial: Ink Spill – A “Flood It” Clone

Welcome to the Code Comments Tutorial for Ink Spill. 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.

UPDATE: I’ve since created a “fancy version” of the game that adds some nice images and variable board sizes and difficulty settings. The zip file can be downloaded below.

Ink Spill source code with comments.

Ink Spill source code without comments.

Ink Spill .exe executable Windows binary (no need to download Python & Pygame)

Fancy version of Ink Spill (source and executable)

How To Play Ink Spill:

Click on the colored palettes at the bottom to change the color of the top left box. Any boxes connected to this box with the same color will also have their color changed. The goal of the game is to turn the entire board to a single color before running out of turns.

5 comments.

  1. This is such a fantastic thing to do, I really hope you continue to do Code Comments. Also the book is wonderful. This site is wonderful! You are wonderful!

  2. Awesome resource for a learner. Many thanks! :)

  3. Hey there, would anyone know how to code this game in MATLAB? any help would be appreciated!!

  4. hey,I’m customer of your book.your book is so great!.i’m closer to finish your book and i’ll make the game in The Code Comments Tutorial that you made.and i would like to make 2D-RPG game like final fantasy or any J-rpg,Could you make tutorial to make rpg game and how to save/load the game? or please write the book to making advanced game(like rpg)?.Surely,i will buy that book!! thank you ^^

  5. Hey Al

    I am studying python 3 at university for com sci and have found your book and website very useful for understanding my courses. I was wondering why you do not use classes? A number of your programs would be even simpler with classes. An example of this is your gemgem game, truly some awesome and neatly fitting code you have there. Perhaps a class could be used instead of the dictionairies, also maybe a class for colour. I would like to re-write your gem gem code and include some classes, may I have your permission to do so – I will leave all comments as they are.

    May I email them to you once I am complete or do you wish me to post it in another comment?

    I am aware that you are making it as simple as possible, but I wish to expand my knowledge and perhaps use some advanced concepts, like classes, inheritance as these are part of my first year course.

Post a comment.

Switch to our mobile site