Arcade: A Primer on the Python Game Framework

by Jon Fincher Jan 15, 2020 intermediate python

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.

The 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 arcade library
  • Draw items on the screen
  • Work with the arcade Python game loop
  • Manage on-screen graphic elements
  • Handle user input
  • Play sound effects and music
  • Describe how Python game programming with arcade differs from pygame

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:

Background and Setup

The 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 pygame:

  • 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

To install arcade and its dependencies, use the appropriate pip command:

$ python -m pip install arcade

On the Mac, you also need to install PyObjC:

$ python -m pip install PyObjC arcade

Complete installation instructions based on your platform are available for Windows, Mac, Linux, and even Raspberry Pi. You can even install arcade directly from source if you’d prefer.

This tutorial assumes you’re using arcade 2.1 and Python 3.7 throughout.

Basic arcade Program

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:

当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
若有不妥, 欢迎评注提醒:


订阅 substack 体验古早写作:

点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:


关于 ~ DebugUself with DAMA ;-)
公安备案号: 44049002000656 ...::