Arcade Game Development Library
npx @tessl/cli install tessl/pypi-arcade@3.3.0A comprehensive Python 2D game development library that provides a complete framework for creating games, simulations, and interactive applications. Arcade offers modern OpenGL rendering, comprehensive sprite management, multiple physics engines, built-in GUI framework, and extensive drawing capabilities for both beginners and advanced developers.
pip install arcadeimport arcadeFor specific functionality:
from arcade import gui, math, color, key, types
from arcade.gl import Context, Buffer, Program
from arcade.camera import Camera2Dimport arcade
class GameWindow(arcade.Window):
def __init__(self, width=800, height=600, title="Game"):
super().__init__(width, height, title)
arcade.set_background_color(arcade.color.AMAZON)
# Initialize sprite lists
self.player_list = None
self.wall_list = None
def setup(self):
# Create sprite lists
self.player_list = arcade.SpriteList()
self.wall_list = arcade.SpriteList()
# Create player sprite
self.player_sprite = arcade.Sprite(":resources:images/animated_characters/female_adventurer/femaleAdventurer_idle.png", 0.5)
self.player_sprite.center_x = 64
self.player_sprite.center_y = 120
self.player_list.append(self.player_sprite)
def on_draw(self):
self.clear()
# Draw all sprite lists
self.player_list.draw()
self.wall_list.draw()
# Draw some shapes
arcade.draw_circle_filled(300, 300, 50, arcade.color.RED)
arcade.draw_rectangle_filled(400, 300, 100, 80, arcade.color.BLUE)
def on_key_press(self, key, modifiers):
if key == arcade.key.UP:
self.player_sprite.change_y = 5
elif key == arcade.key.DOWN:
self.player_sprite.change_y = -5
elif key == arcade.key.LEFT:
self.player_sprite.change_x = -5
elif key == arcade.key.RIGHT:
self.player_sprite.change_x = 5
def on_key_release(self, key, modifiers):
if key in (arcade.key.UP, arcade.key.DOWN):
self.player_sprite.change_y = 0
elif key in (arcade.key.LEFT, arcade.key.RIGHT):
self.player_sprite.change_x = 0
def on_update(self, delta_time):
# Update sprite positions
self.player_list.update()
# Create and run the game
def main():
window = GameWindow()
window.setup()
arcade.run()
if __name__ == "__main__":
main()Arcade is built around several core architectural components:
arcade.gl wrapperThis architecture enables Arcade to scale from simple educational projects to complex commercial games while maintaining performance and ease of use.
Comprehensive 2D drawing functions including filled shapes, outlines, lines, points, and texture rendering with support for colors, gradients, and batch operations.
def draw_circle_filled(center_x: float, center_y: float, radius: float, color: arcade.types.Color) -> None: ...
def draw_rectangle_filled(center_x: float, center_y: float, width: float, height: float, color: arcade.types.Color) -> None: ...
def draw_line(start_x: float, start_y: float, end_x: float, end_y: float, color: arcade.types.Color, line_width: float = 1) -> None: ...
def draw_texture_rect(texture: arcade.Texture, rect: arcade.types.Rect, alpha: int = 255) -> None: ...Complete sprite management system with animated sprites, sprite lists, spatial indexing, and comprehensive collision detection for game object interactions.
class Sprite:
def __init__(self, filename: str = None, scale: float = 1, **kwargs): ...
center_x: float
center_y: float
change_x: float
change_y: float
class SpriteList:
def __init__(self, **kwargs): ...
def append(self, sprite: arcade.Sprite) -> None: ...
def draw(self, **kwargs) -> None: ...
def update(self) -> None: ...
def check_for_collision(sprite1: arcade.Sprite, sprite2: arcade.Sprite) -> bool: ...
def check_for_collision_with_list(sprite: arcade.Sprite, sprite_list: arcade.SpriteList) -> list: ...Sprite System and Collision Detection
Window lifecycle management, view system for game states, sections for viewport management, and event handling for user input.
class Window(pyglet.window.Window):
def __init__(self, width: int = 800, height: int = 600, title: str = "Arcade Window", **kwargs): ...
def on_draw(self) -> None: ...
def on_update(self, delta_time: float) -> None: ...
def on_key_press(self, key: int, modifiers: int) -> None: ...
class View:
def __init__(self): ...
def on_show_view(self) -> None: ...
def on_hide_view(self) -> None: ...
def open_window(width: int, height: int, title: str = "Arcade Window") -> arcade.Window: ...
def run() -> None: ...Window and Application Management
Multiple physics engine options from simple AABB collision to advanced 2D physics simulation with Pymunk integration for realistic physics behavior.
class PhysicsEngineSimple:
def __init__(self, player_sprite: arcade.Sprite, walls: arcade.SpriteList): ...
def update(self) -> None: ...
class PhysicsEnginePlatformer:
def __init__(self, player_sprite: arcade.Sprite, platforms: arcade.SpriteList, gravity_constant: float = 0.5, ladders: arcade.SpriteList = None): ...
def update(self) -> None: ...
class PymunkPhysicsEngine:
def __init__(self, gravity: tuple = (0, -981)): ...
def add_sprite(self, sprite: arcade.Sprite, **kwargs) -> None: ...
def step(self, delta_time: float = 1/60) -> None: ...Texture loading, caching, atlas management, procedural texture generation, and sprite sheet handling for efficient graphics resource management.
class Texture:
def __init__(self, image: PIL.Image.Image, name: str = None): ...
width: int
height: int
def load_texture(file_path: str, **kwargs) -> arcade.Texture: ...
def make_circle_texture(diameter: int, color: arcade.types.Color) -> arcade.Texture: ...
class SpriteSheet:
def __init__(self, file_path: str, sprite_width: int, sprite_height: int, **kwargs): ...
def get_texture(self, x: int, y: int) -> arcade.Texture: ...Audio playback with support for multiple formats, volume control, spatial audio, and sound effect management for immersive game experiences.
class Sound:
def __init__(self, file_path: str): ...
def play(self, volume: float = 1.0, pan: float = 0.0, loop: bool = False) -> None: ...
def stop(self) -> None: ...
def load_sound(file_path: str) -> arcade.Sound: ...
def play_sound(sound: arcade.Sound, volume: float = 1.0) -> None: ...Complete user interface framework with widgets, layouts, event handling, styling, and theming for creating game menus and interfaces.
class UIManager:
def __init__(self, window: arcade.Window = None): ...
def add(self, widget: arcade.gui.UIWidget) -> None: ...
def on_draw(self) -> None: ...
class UIFlatButton(arcade.gui.UIInteractiveWidget):
def __init__(self, text: str, width: float = 100, height: float = 50, **kwargs): ...
class UIBoxLayout(arcade.gui.UILayout):
def __init__(self, vertical: bool = True, **kwargs): ...2D camera system with view transformations, viewport management, projection controls, and smooth camera movement for dynamic view control.
class Camera2D:
def __init__(self, viewport: arcade.types.Rect = None): ...
def move_to(self, position: tuple, speed: float = 1.0) -> None: ...
def use(self) -> None: ...
position: arcade.math.Vec2
zoom: floatMathematical functions, vector operations, geometric utilities, color types, and game-specific calculations for game development.
def get_distance(x1: float, y1: float, x2: float, y2: float) -> float: ...
def get_angle_degrees(x1: float, y1: float, x2: float, y2: float) -> float: ...
def lerp(a: float, b: float, t: float) -> float: ...
class Vec2:
def __init__(self, x: float = 0, y: float = 0): ...
x: float
y: float
# Type definitions
RGB = tuple[int, int, int]
RGBA = tuple[int, int, int, int]
Point = tuple[float, float]Advanced features including particle systems, A* pathfinding, performance monitoring, tilemap support, and experimental rendering effects.
class Emitter:
def __init__(self, center_xy: tuple, emit_controller: arcade.EmitController, particle_factory: callable): ...
def update(self) -> None: ...
def astar_calculate_path(start_point: tuple, end_point: tuple, barriers: arcade.AStarBarrierList, diagonal_movement: bool = True) -> list: ...
class PerfGraph:
def __init__(self, width: int, height: int, graph_data: str): ...
def draw(self) -> None: ...# Color types
RGB = tuple[int, int, int]
RGBA = tuple[int, int, int, int]
RGBOrA = RGB | RGBA
Color = arcade.types.Color
# Geometry types
Point = tuple[float, float]
Point2 = tuple[float, float]
Point3 = tuple[float, float, float]
PointList = list[Point]
# Rectangle types
class Rect:
def __init__(self, x: float, y: float, width: float, height: float): ...
x: float
y: float
width: float
height: float
class LRBT:
def __init__(self, left: float, right: float, bottom: float, top: float): ...
class LBWH:
def __init__(self, left: float, bottom: float, width: float, height: float): ...
# Vector types (from pyglet.math)
class Vec2:
def __init__(self, x: float = 0, y: float = 0): ...
x: float
y: float
class Vec3:
def __init__(self, x: float = 0, y: float = 0, z: float = 0): ...
x: float
y: float
z: float# Mouse buttons
MOUSE_BUTTON_LEFT: int = 1
MOUSE_BUTTON_MIDDLE: int = 2
MOUSE_BUTTON_RIGHT: int = 4
# Sprite directions
FACE_LEFT: str = "left"
FACE_RIGHT: str = "right"
FACE_UP: str = "up"
FACE_DOWN: str = "down"
# Version
VERSION: str = "3.3.2"