Discover Python and Patterns (3): Branching

Programs in the previous post always lead to the same result. Here, I show you the basics of branching, or how to change the flow of a program depending on cases.

Continue reading
Posted in Tutorial | Tagged | Leave a comment

Discover Python and Patterns (2): Basic interaction

In the first post, we saw how to install an IDE and how to display a message; it is time to add some interaction with the player.

Continue reading
Posted in Tutorial | Tagged | Leave a comment

Discover Python and Patterns (1): Start

In this series, I propose to discover Python and design patterns. The Python language is today one of the best language to discover programming. At the same time, I will also introduce design patterns, a collection of programming recipes that give many good ideas when creating programs. In this first post, we see the Spyder IDE and the print() function.

Continue reading
Posted in Tutorial | Tagged | Leave a comment

The paperback version of my book is out!

The paperback version of my book “Learn Design Patterns with Game Programming” is finally out!

The Kindle version is updated with some improvements and is still freely available if you subscribed to Kindle Unlimited.

Posted in News | Tagged | Leave a comment

AWT GUI Facade (8): Keyboard and key sequences

In this post, I add the keyboard management to the facade, and I propose a way to detect key sequences. These sequences are used, for example, in games like Street Fighter II, where characters move according to specific key combos.

Continue reading
Posted in Tutorial | Tagged , , , , | Leave a comment

AWT GUI Facade (7): Draw text

Graphic libraries usually provide methods to draw text on the screen. These handy methods are often quite slow to run because they recompute many parameters at each call. To save computational time, the flyweight pattern can be used to provide text parameters with low memory and cpu usage.

Continue reading
Posted in Tutorial | Tagged , , , | Leave a comment

AWT GUI Facade (6): Mouse and Game Loop

After loading a level, I now propose to add interaction with the use of a mouse. This will be an opportunity to see two other patterns: the Observer Pattern to handle mouse events, and the Game Loop Pattern for synchronization between controls, updates, and display.

Continue reading
Posted in Tutorial | Tagged , , , | Leave a comment

AWT GUI Facade (5): Load a level

In this article, I propose to use the Visitor Pattern to easily load a level. The GUI facade in the previous post is used to display the level. This pattern allows (among other things) to easily browse a data structure to extract information. In our case, it is an XML file created by “Tiled Map Editor” which is analyzed to load a level in memory.

Continue reading
Posted in Tutorial | Tagged , | Leave a comment

AWT GUI Facade (4): Draw with tiles

I continue the extension of the graphic facade (see previous article), with here the addition of a very classic form of drawing for video games: tiles. These make it possible to compose an image using small images called tiles. There are several types of tiles, I propose in this article the simplest case with rectangular tiles.

Continue reading
Posted in Tutorial | Tagged , , , | Leave a comment

AWT GUI Facade (3): Display an image

The facade seen in the previous article has only an interface with its methods. It is also possible to enrich a facade with additional interfaces, connected to each other by various means. To illustrate it, I propose to add image management. This addition also makes it possible to present another design pattern: the Factory Method Pattern.

Continue reading
Posted in Tutorial | Tagged , , , | Leave a comment