Now, you will add comments to your main.py
file. Comments are like notes that explain what your code does. They help you and others understand your game better.
Look for the Ball
and Paddle
parts of your code. Add comments to explain what each part does. For example, you can explain what the Ball
class is for, or what the move
function does.
Also, find the main part of your game code (the game loop). Add comments to explain the different steps, like when the game starts, when it checks for player actions, when it updates the game, and when it draws things on the screen.
Here's how you add comments in Python:
# This is a single-line comment
def my_function():
"""This is a multi-line comment (docstring)
It explains what the function does.
"""
pass
Remember to explain what your code does, not just how it does it.