Computer games are a great way to introduce people to coding and computer science. Since I was a player in my youth, the lure of writing video games was the reason I learned to code. Of course, when I learned Python, my first instinct was to write a Python game.
While Python makes learning to code more accessible for everyone, the choices for video game writing can be limited, especially if you want to write arcade games with great graphics and catchy sound effects. For many years, Python game programmers were limited to the
pygame framework. Now, there’s another choice.
arcade library is a modern Python framework for crafting games with compelling graphics and sound. Object-oriented and built for Python 3.6 and up,
arcade provides the programmer with a modern set of tools for crafting great Python game experiences.
In this tutorial, you’ll learn how to:
- Install the
- Draw items on the screen
- Work with the
arcadePython game loop
- Manage on-screen graphic elements
- Handle user input
- Play sound effects and music
- Describe how Python game programming with
This tutorial assumes you have an understanding of writing Python programs. Since
arcade is an object-oriented library, you should also be familiar with object-oriented programming as well. All of the code, images, and sounds for this tutorial are available for download at the link below:
Download Assets: Click here to download the assets you'll use to make a game with arcade in this tutorial.
Background and Setup
arcade library was written by Paul Vincent Craven, a computer science professor at Simpson College in Iowa, USA. As it’s built on top of the
pyglet windowing and multimedia library,
arcade features various improvements, modernizations, and enhancements over
- Boasts modern OpenGL graphics
- Supports Python 3 type hinting
- Has better support for animated sprites
- Incorporates consistent command, function, and parameter names
- Encourages separation of game logic from display code
- Requires less boilerplate code
- Maintains more documentation, including complete Python game examples
- Has a built-in physics engine for platform games
arcade and its dependencies, use the appropriate
$ python -m pip install arcade
On the Mac, you also need to install
$ python -m pip install PyObjC arcade
Note: More recent versions of
arcade utilize data classes, which are included in Python only for version 3.7 and later.
However, a backport is available on PyPI for Python 3.6 that you can install using
$ python -m pip install dataclasses
See The Ultimate Guide to Data Classes in Python 3.7 for more information.
This tutorial assumes you’re using
arcade 2.1 and Python 3.7 throughout.
Before you dig in, let’s take a look at an
arcade program that will open a window, fill it with white, and draw a blue circle in the middle: