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.

Continue reading
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.

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

Model-View-Controller pattern with Unity

I found a very interesting post on using the Model-View-Controller pattern:

https://www.toptal.com/unity-unity3d/unity-with-mvc-how-to-level-up-your-game-development

Although the article uses Unity, it covers some very interesting general concepts.

Posted in Link | 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.

Continue reading
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.

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

Discover Python and Patterns (7): Functions

It is now time to organize/refactor our code! When you begin, this is a strange process since the final code does the same as before. However, refactoring is the only way to create a code easy to maintain and expand.

Continue reading
Posted in Tutorial | Tagged | Leave a comment

Discover Python and Patterns (6): Random

In the previous post, the magic number is always the same. I propose now to introduce random numbers to change the magic number every time we launch the game. I also present imports and more on integers.

Continue reading
Posted in Tutorial | Tagged | Leave a comment

The source code of my book is now available on github

The source code of my book "Learn Design Pattern with Game Programming" is now available on github

The source code of my book “Learn Design Pattern with Game Programming” is now available on github: https://github.com/philippehenri-gosselin/patternsgameprog.

If you find any bug, comments here or issues on github are welcome 🙂

Posted in Tutorial | Tagged | Leave a comment

Discover Python and Patterns (5): Integers

In previous posts, I only used strings and booleans. In this one, I use a new data type called “int” (for integer) that allows the storage and computation of natural numbers (numbers without a decimal part). I use them to create the famous “guess the number” game!

Continue reading
Posted in Tutorial | Tagged | Leave a comment

Discover Python and Patterns (4): Loops

The previous game only allows one try: you have to restart it to propose another word. In this post, I introduce loops, and I use them to repeat the game until the player finds the magic word.

Continue reading
Posted in Tutorial | Tagged | Leave a comment