Tag Archives: Python

Discover Python and Patterns (17): 2D arrays

We still have no background in our game: I add one in this post using 2D arrays.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (16): Inheritance

In this post, I present the basics of class inheritance, to represent our units (the tank and the canon tower) more efficiently.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (15): Lists

I introduce in this post Python lists: with them, we can store and process any number of items, for instance, all the canon towers in our game.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (14): Collisions

In this post, I add enemies and I show you how to test if the tank collides one of them.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (13): Sprites

In this post, I propose to replace the rectangle in the previous program with a tank sprite, using a tileset.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (12): Command pattern

The implementation of the Game Loop pattern in the previous post is not good: I propose to use the Command pattern to get a better one. This pattern allows separating input handling and game updating.

Posted in Tutorial | Tagged , , | Leave a comment

Discover Python and Patterns (11): Class

I propose to introduce Python classes to implement the Game Loop pattern. Using these tools, I show how to refactor the code in the previous post to get a more robust and readable program.

Posted in Tutorial | Tagged , , | Leave a comment

Discover Python and Patterns (10): Keyboard

Thanks to the Pygame library we installed in the previous post, we can draw 2D graphics. In this post, I propose to introduce controls with the keyboard as well as some improvements like window centering and frame rate handling.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (9): Pygame

In the previous posts, I introduced enough of Python and patterns to start creating games with graphics using the Pygame library.

Posted in Tutorial | Tagged , | Leave a comment

Discover Python and Patterns (8): Game Loop pattern

The time has come to see our first design pattern: the Game Loop Pattern! This pattern can give us many good ideas to refactor our game in a very effective way.

Posted in Tutorial | Tagged , | Leave a comment