PY-1.4-BP4-MQ20

Our Goal: Organize Your Game Files

In this lesson, you will learn how to organize your game files. This is like putting your toys in the right boxes so you can find them easily. You will make a main folder for your game, put your Python code inside it, and then make another folder inside for pictures or sounds (called 'assets'). This will help you get your game ready to share online.

Check Your Folders

Before you organize your files, let's check your folders. We will run a test to see if the folders are set up correctly.

Run this command in your terminal:

pytest module-1.4/blueprint-BP4/quest-20

What you should see:

āŒ Some tests will fail. This is okay for now! It means the folders are not yet organized, and the tests are waiting for you to do it.

Organize Your Files

Now, you will write code to organize your game files. You will create a main folder for your project and a sub-folder inside it for your game's pictures and sounds.

Here's how you can create folders in Python:

import os

# Create a new folder
os.makedirs("my_new_folder", exist_ok=True)

# Create a sub-folder inside it
os.makedirs("my_new_folder/sub_folder", exist_ok=True)

Use these ideas to create your main game folder and an 'assets' folder inside it. Remember to put your main Python game script in the main folder.

Check Your Work Again

You've organized your files! Now, let's run the tests to make sure your folders are set up correctly.

Run this command in your terminal:

pytest module-1.4/blueprint-BP4/quest-20

What you should see:

āœ… All tests should pass! This means your folders are now organized correctly.

Documentation

Documentation not available for PY-1.4-BP4.