Building Games with Python

Jordan Hurst reviewed steps to take when creating the initial build of a game in Python. When adding the libraries to import to start building a game, a very useful library to include is pygames, which gives developers several resources to help with their build.

After the imports are added to the code, the actual build of the game can start with a class for the game and an initiator. Within the initiator developers can set the height and width of the window, add a title, and more.

In order to start the game, a function is needed to open the window with the specifications listed in the initiator; once defined, that function can be called to start the game.

To keep the game running a while, true loop is needed and within that loop developers can check for any events that may occur in the game, including the QUIT event, which will require logic to close out the window.

After taking these steps for the initial build of the game, developers can use functions like bg_color to change the background color, create a settings file to store the height, width, background color, etc., and create additional files with classes to complete other actions, like adding pictures to the screen.

Previous
Previous

OutSystems Front-end Developer and Security Specialization

Next
Next

Computer Science & Problem Sets