Arcade Game Development Library

repository·development·Indexed 24 days ago

https://github.com/pythonarcade/arcade

A Python library for 2D game development built on top of pyglet and OpenGL. It provides tools for managing game windows, textures, and sprites, as well as an InputManager for handling discrete actions and continuous axes from keyboards, mice, and controllers. The library includes support for headless mode, HiDPI scaling, and a web playground for testing scripts via Pyodide.

Tokens
91.8K
Snippets
121
Records
651
Agent score
84%

What's inside arcade

  1. Overview of the Arcade GUI module

    development

    The arcade.gui module provides classes for user interface interaction, including buttons, labels, and various layout components.

    Key Technical Detail: The GUI uses a specialized rendering system distinct from the main engine rendering. This system is specifically designed to handle the resizing and scaling of widgets reliably, avoiding common issues found in standard engine rendering when UI elements change size.

  2. Supported platforms for Arcade

    development

    Arcade is compatible with the following platforms:

    • Desktop: Windows, Mac, and Linux. Most hardware with an Intel or AMD processor from the last ten years is supported. (Note: New Mac M-series hardware may encounter minor issues but generally works).
    • Single Board Computers (SBCs):
      • Raspberry Pi: Raspberry Pi 4, Raspberry Pi 5, and potentially Raspberry Pi 400 (running Raspberry Pi OS) are supported.
      • Unsupported: As of October 2024, all other Raspberry Pi models are incompatible.
      • Other SBCs: May work with Arcade 3.0.0+; check specific requirements for your hardware.

    Unsupported Platforms:

    • Web: Not currently supported (waiting for WebGPU/WASM maturity).
    • Mobile (Android/iOS/iPad): Not supported in the foreseeable future due to required changes in Arcade and the underlying pyglet library.
  3. Explore sample games made with Arcade

    development

    The Arcade community has created a wide variety of games ranging from top-down shooters and platformers to turn-based tactics and simulations. You can find inspiration or study existing codebases by exploring user-submitted projects on platforms like itch.io and GitHub.

    Key categories of community games include:

    • Top-down shooters/survival: e.g., Brazier, PhotoShip, SOL Defender, BoxHead Survivor.
    • Tactics/Strategy: e.g., Temporum, Age of Divisiveness.
    • Platformers/Side-view: e.g., Kayzee, FlapPy Bird.
    • Simulations/Animations: e.g., Eight planet simulation, Transcience Animation.
    • Classic Re-implementations: e.g., Space Invaders.
  4. Commercial use and licensing in Arcade

    development

    Arcade is licensed under the MIT License, making it commercially friendly. You can use Arcade to create and sell games without paying fees or dealing with complicated licensing red tape.

    Key points:

    • Code: The arcade package uses the MIT License. You must not claim you wrote the entire library yourself.
    • Resources: Built-in assets are high-quality and generally public domain (CC0) or similar, meaning they do not require attribution for most users.
    • Commercial Example: Spelly Cat is a commercially available game on Steam made with Arcade.
  5. Experimental video playback support in Arcade

    development

    Arcade provides experimental support for video playback using pyglet and other libraries. Because these features are works-in-progress, they are located in the experimental folder of the development branch and are subject to change.

    To use advanced video features like those based on OpenCV (cv2), you may need to install ffmpeg and additional libraries as described in the supported media guide.

  6. Arcade Skill Tree: Core Concepts and Features

    development

    The Arcade library covers a wide range of game development topics. Key areas of study include:

    Drawing and Sprites

    • Basic Drawing: Use drawing primitives or batch thousands of commands using arcade.shape_list.ShapeElementList for performance.
    • Sprites: The arcade.Sprite class is the primary way to handle game objects. You can manage hit boxes via arcade.Sprite.hit_box.
    • Animation: Change textures on sprites to create animations.

    Movement and Physics

    • Player Movement: Supports Mouse, Keyboard (including acceleration/deceleration and rotation), and Game Controllers.
    • Non-Player Movement: Includes bouncing, following players (with or without delay), A-star pathfinding, and line-of-sight logic.
    • Physics Engines:
      • PhysicsEngineSimple: Good for basic platformers.
      • PhysicsEnginePlatformer: Supports ladders and moving platforms.
      • Pymunk: For advanced top-down or platformer physics.

    Game Systems

    • Collision Detection: Includes basic detection, spatial hashing for performance, and sprite hit box management.
    • View and Window Management: Use Views for screens (pause, instructions, game over) and manage windows for scrolling, full-screen, or resizing.
    • Map Creation: Supports programmatic placement (loops/lists), procedural generation (mazes, caves), and TMX (Tiled) maps.
    • Audio: Supports music control and spatial sound.
    • GUI and Particles: Dedicated systems for user interfaces and particle effects.

    Advanced Graphics (OpenGL)

    • Shaders: Write shaders using "ShaderToy" style or implement custom effects like CRT filters, lighting, and ray-cast shadows.
    • Compute Shaders: Support for compute shader implementation.
  7. Supported Backends for arcade.gl

    development

    OpenGL Backend

    The current implementation is the OpenGL/GLES wrapper in arcade.gl.backends.opengl. It requires:

    • OpenGL 3.3+
    • OR GLES with certain extensions

    It uses Python's ctypes via pyglet and Arcade's own bindings to avoid binary dependencies, ensuring portability across most desktop/laptop hardware from the last decade.

    Web Backend (In Development)

    Work is ongoing to implement a WebGPU backend that runs locally in-browser via pyodide for better performance and feature parity with desktop.

  8. Compare Arcade with Pygame

    development

    Arcade and Pygame are both Python libraries for 2D game development, but they use different underlying technologies:

    • Arcade: Uses OpenGL (via Pyglet). It is optimized for drawing sprites, off-loading rotation, scaling, and transparency to the GPU. It excels at high sprite counts and features built-in support for cameras, views, lighting, GUI, and Tiled maps.
    • Pygame (Original & CE): Uses SDL 2 and is raster-graphics based. It is very fast at manipulating individual pixels and is highly portable (supporting Android and Raspberry Pi), but transformations like rotation and scaling are performed on the CPU.

    Key Feature Differences

    FeatureArcadePygame
    Rotation/ScalingGPU-acceleratedCPU-based (expensive)
    Texture AtlasYes (automatic)No
    Camera SupportYesNo
    Physics EnginesSimple, Platformer, PyMunkNone
    GUI SupportYesVia add-ons (e.g., pygame-gui)
    GPU ShadersYesNo
    Tiled Map SupportYesNo
  9. Introduction to Shaders in Arcade

    development

    Shaders are small programs that specify how graphics hardware draws and shades objects. They provide significantly more power, flexibility, and efficiency than using standard shapes or arcade.Sprite instances alone.

    Arcade supports various types of shaders, including:

    • Pixel Shaders (Shadertoy style): These operate in "screen space" and are a subset of shader capabilities. Many tutorials in this library focus on this style.
    • Geometry Shaders: Used for manipulating geometry.
    • Compute Shaders: Used for generic GPU-based processing.

    Note that while Shadertoy-style shaders are common, they are only one way to use the GPU within Arcade.