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.

Simulate source code without comments.

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

How To Play Simulate:

The game plays a pattern of lights for the four colored buttons. After the pattern is done playing, try to repeat the pattern by clicking on the colored buttons in the same order. If you complete the pattern correctly, the pattern gets longer and longer. This is a great game to train your short term memory skills.

2 comments on this post.
  1. izzet can:

    well done!

  2. bitboy:

    So good! Congratzs :)

Leave a comment