Pygame Comparison#

Both Pygame and Arcade are Python libraries for making it easy to create 2D games. Pygame is raster-graphics based. It is very fast at manipulating individual pixels and can run on almost anything. Arcade uses OpenGL. It is very fast at drawing sprites and off-loads functions such as rotation and transparency to the graphics card.

Here are some comparisons between Arcade 2.6 and Pygame 2.0.1:

Library Information#

Feature

Arcade

Pygame

Website

https://arcade.academy

https://www.pygame.org

API Docs

API Docs

API Docs

Example code

Example Code

N/A

License

MIT License

LGPL

Back-end graphics engine

OpenGL 3.3+ and Pyglet

SDL 2

Back-end audio engine

ffmpeg via Pyglet

SDL 2

Example Projects

Games Made With Arcade

Games Made With Pygame

Feature Comparison#

Feature

Arcade

Pygame

Drawing primitives support rotation

Yes

No 1

Sprites support rotation

Yes

No 1

Sprites support scaling

Yes

No 1

Sprite image caching 2

Yes

No

Type Hints

Yes

No

Transparency support

Yes

Must specify transparent colorkey

Camera support

Yes

No

Android support

No

Yes

Raspberry Pi support

No

Yes

Batch drawing

Via GPU

Via Surface 3

Default Hitbox

../_images/hitbox_simple.png ../_images/hitbox_none.png

Tiled Map Support

Yes

No

Physics engines

Simple, platformer, and PyMunk

None

Event Management

Pyglet-based

No (or add Pygame Zero)

View Support

Yes

No

Light Support

Yes

No

GUI Support

Yes

No (or add pygame-gui)

GPU Shader Support

Yes

No

Built-in Resources

Yes

No

Performance Comparison 4#

Feature

Arcade

Pygame

Draw 50,000 stationary sprites

0.001 seconds

0.425 seconds

Move 5,000 sprites

0.010 seconds

0.003 seconds

# sprites program can move + draw before FPS drops below 55

8500

2000

Collision detection 50,000 sprites

0.044 seconds no spatial hashing 5
0.005 seconds with spatial hashing

0.004 seconds 6

Draw 5,000 plain rectangles 7

0.081 seconds

0.008 seconds

Draw 5,000 rotated rectangles 8

0.081 seconds

0.029 seconds

../_images/fps_comparison2.svg

FPS comparison of programs drawing stationary sprites.#

../_images/fps_comparison1.svg

FPS comparison of programs drawing moving sprites.#

1(1,2,3)

To support rotation and/or scaling, PyGame programs must write the image to a surface, transform the surface, then create a sprite out of the surface. This takes a lot of CPU. Arcade off-loads all these operations to the graphics card.

2

When creating a sprite from an image, Pygame will load the image from the disk every time. The user must cache the image with their own code for better performance. Arcade does this automatically.

3

A programmer can achieve a similar result by drawing to a surface, then drawing the surface to the screen.

4

Performance tests done on an Intel Core i7-9700F with GeForce GTX 980 Ti. Source code for tests available at https://github.com/pythonarcade/performance_tests and more detailed results at https://craven-performance-testing.s3-us-west-2.amazonaws.com/index.html

5

Polygon hit box, rotation allowed

6

Rectangular hit box, no rotation allowed

7

Why is Arcade so slow here? With PyGame, most of the drawing is done on the CPU side. Bitmaps are created and manipulated by the CPU. It is pretty fast. With Arcade, most of the drawing happens on the GPU side. Sprites and drawings are batched together, and we just tell the GPU what we want to change. Or better yet, we write a “shader” program that runs completely on the GPU. This is incredibly fast. But if instead a CPU program runs commands to draw individual GPU items one-by-one, both sets of processors wait for a synchronous communication. That is horribly slow. Drawing individual rects and bits like PyGame does, won’t work well at all on Arcade. Use sprites, shaders, or batch-drawing to get fast performance.

8

Scaling and rotation must be done by the programmer drawing to a surface, transforming the surface, then blit’ing the surface to the screen. Arcade uses the GPU for these operations and needs no additional code or performance hits.