Use PyInstaller to Create Executable of Python PgZero Game – Windows Version

If you develop a game with Pgzero or PyGame, you might want to invite your friends to play it. However, some of your friends do not use Python, so they do not have the Python development environment, or you do not want to share your Pgzero code at that moment. How do you wrap your …

Continue reading Use PyInstaller to Create Executable of Python PgZero Game – Windows Version

Code Structure Change When Converting Blockly Language into Pyton Code for LEGO MindStorms

When we start to write Python code for LEGO MindStorms models, we tend to convert existing Scratch blockly code into Python version and check if it works. Although LEGO has made effort to create Python methods which could match the functionality of Scratch programming blocks, the Python code structure is much different from that of …

Continue reading Code Structure Change When Converting Blockly Language into Pyton Code for LEGO MindStorms

Use LEGO MindStorms Inventor to Build a Pet Dog – Code it with Both Blockly Language and Python – Part Two

In the previous post, I introduced how to use blockly language to control LEGO MindStorms Inventor, and write code for the pet dog. As I have already mentioned, we could accomplish the similar functionalities by using Python. In today's post, we will use the Python editor of LEGO MindStorms Inventor App to implement the same …

Continue reading Use LEGO MindStorms Inventor to Build a Pet Dog – Code it with Both Blockly Language and Python – Part Two

Use LEGO MindStorms Smart Hub to Design a Dodge Game – This Time Using Python

This post is closely related to my previous post - use LEGO MindStorms Smart Hub to design a dodge game. The difference is that in this project, I will use Python to implement the same functionality as I did in the previous post. If you are interested, you could open the two posts side by …

Continue reading Use LEGO MindStorms Smart Hub to Design a Dodge Game – This Time Using Python

A Self-help Guide to Learn Pgzero and Develop Python Games

If you have read my previous post PyGame is too complicated? Try PgZero, you might have an impression that Pgzero is much simpler to be used than PyGame. On the other hand, you might think it could only develop some simple games. Actually, using proper tools, we could use Pgzero to develop any games which …

Continue reading A Self-help Guide to Learn Pgzero and Develop Python Games

Find Maximum Prime Factor of a Number by Using Python – Algorithm Explanation

Recently, I am teaching students algorithm using Python. One question is to find maximum prime factor of a given number. When we consider algorithm, we should consider both the running time and occupied memory of the program when the input is an extremely big number. The following algorithm is very typical to get the prime …

Continue reading Find Maximum Prime Factor of a Number by Using Python – Algorithm Explanation

PyGame is too complicated? Try PgZero

In my previous posts, I introduced how to use PyGame to design 2D games with Python language. Pygame adds functionality on top of the excellent SDL library. User controls the main loop, designs their program functions and different sprites' interaction. This gives user greater control in creating fully featured games and multimedia programs in the Python …

Continue reading PyGame is too complicated? Try PgZero

From PyGame to GoDot – What’s Their Difference?

About PyGame If you would like to use Python to develop 2D game, your first choice might be PyGame, which is popular among Python game developers. Go to the website https://www.pygame.org/docs/ref/key.html, you could browse all of the classes and their explanation. All of the stuffs are grouped into the pygame library. If you do not …

Continue reading From PyGame to GoDot – What’s Their Difference?

Use PyGame to Create Tetris Game – An Updated Version Part 2

In my previous post, I introduced the first part of Tetris game written in Python. Today, let's continue the left part of the code. In the first part, we have introduced the class Piece and several functions which will be used by the main() function. Now, let's see what the main() function is doing. Starting …

Continue reading Use PyGame to Create Tetris Game – An Updated Version Part 2

Use PyGame to Create Tetris Game – an Updated Version

In the previous posts, I once analyzed a Tetris game developed in Scratch. It uses Pen drawing tab to draw all the tetris pieces. However, due to the limitation of data structure in Scratch, the code structure is super complicated compared to other Scratch projects. How about we implement it in Python? On YouTube, some …

Continue reading Use PyGame to Create Tetris Game – an Updated Version