This repository contains source code for sample games that you'll see in Real Python's Top Python Game Engines tutorial.
After cloning this repository, you can navigate into each folder to find the source code for the sample games shown in the tutorial. Instructions on how to run each game is shown below.
It's recommended to use a virtual environment to run these samples. To do so, follow these instructions.
First, create the virtual environment:
$ python3 -m venv venvNext, activate the virtual environment:
$ source ./venv/bin/activateFinally, install the dependencies for these projects:
(venv) $ python -m pip install -r requirements.txtTo run the Pygame sample code, first activate the virtual environment:
$ source ./venv/bin/activateThen navigate to the Pygame folder:
(venv) $ cd pygameTo run the basic game:
(venv) $ python pygame_basic.pyTo run the full sample game:
(venv) $ python pygame_game.pyTo run the Pygame Zero sample code, first activate the virtual environment:
$ source ./venv/bin/activateThen navigate to the Pygame Zero folder:
(venv) $ cd pygame_zeroTo run the basic game:
(venv) $ python pygame_zero_basic.pyTo run the full sample game:
(venv) $ python pygame_zero_game.pyAlternately, you can use pgzrun to run both games:
(venv) $ pgzrun pygame_zero_game.pyLinters like flake8 are unaware of Pygame Zero's extra built-ins.
That's why you'll find # noqa: F821 inline comments in pygame_zero_basic.py and pygame_zero_game.py.
With the # noqa inline comments flake8 ignores the linter errors that these lines would cause.
To run the Arcade sample code, first activate the virtual environment:
$ source ./venv/bin/activateThen navigate to the Arcade folder:
(venv) $ cd arcadeTo run the basic game:
(venv) $ python arcade_basic.pyTo run the full sample game:
(venv) $ python arcade_game.pyTo run the adventurelib sample code, first activate the virtual environment:
$ source ./venv/bin/activateThen navigate to the adventurelib folder:
(venv) $ cd adventurelibTo run the basic game:
(venv) $ python adventurelib_basic.pyTo run the full sample game:
(venv) $ python adventurelib_game.pyUnlike the other samples, Ren'Py games are developed and run from the Ren'Py Software Development Kit.
Visit the Ren'Py web page to download the proper SDK for your environment (Windows, macOS, and Linux versions are available).
Then, run the Ren'Py Launcher using the proper command for your environment. Check out the Ren'Py Quickstart Guide for the most up-to-date instructions.
To access the basic and full sample games in the Ren'Py launcher, click Preferences, then Projects Directory. Change the Projects Directory to the renpy folder in the repository folder you downloaded. Click Return to return to the main Ren'Py Launcher page.
To run the basic game, click on basic_game in the Projects list on the left, then click Launch Project.
To run the full sample game, click on giant_quest_game in the Projects list on the left, then click Launch Project.