Starting the pygame project
Let’s get the project started. This part of the tutorial is going to be the same for any of the Python projects that you are going to start. Python website if you are using Windows. Most of the Mac and Linux systems come with Python preinstalled. You can check if Python is installed in your system just by using the command.
In this tutorial, I am going to use Python
3.8. But you can follow it with whatever version you have. Please leave your comments when things are not working for your Python version or system.
Installing virtualenvVirtual environment is a way of differentiating different development systems. For example, you can be making different games at a time and you don’t want to mix the installation of one system with the other. You can create a virtualenv using the following command if you are using Python 3.
For starting the virtualenv, just use the command,
python3 -m venv venv
pip install pygame
If you are using PyCharm you can add set your virtual environment as the interpreter using the Pycharm settings/preferences.With everything setup, we are ready to start with the tutorial and building our first game using PyGame.
Checking installationWe can check if the installation was successful by creating a file called
main.pyand adding the following code.
Try running it using
python main.py. If you see a similar response on the console then it is working fine.
pygame 2.0.0 (SDL 2.0.12, python 3.8.6) Hello from the pygame community. https://www.pygame.org/contribute.html
Please share your Feedback:
Did you enjoy reading or think it can be improved? Don’t forget to leave your thoughts in the comments section below! If you liked this article, please share it with your friends, and read a few more!