Arcade Game Development Library
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Mathematical functions, vector operations, geometric utilities, color types, and game-specific calculations for comprehensive game development support.
def clamp(value: float, min_value: float, max_value: float) -> float:
"""Clamp value between minimum and maximum."""
def lerp(start: float, end: float, t: float) -> float:
"""Linear interpolation between two values."""
def lerp_2d(start: tuple[float, float], end: tuple[float, float], t: float) -> tuple[float, float]:
"""2D linear interpolation."""
def get_distance(x1: float, y1: float, x2: float, y2: float) -> float:
"""Calculate distance between two points."""
def get_angle_degrees(x1: float, y1: float, x2: float, y2: float) -> float:
"""Get angle in degrees between two points."""
def get_angle_radians(x1: float, y1: float, x2: float, y2: float) -> float:
"""Get angle in radians between two points."""
def rotate_point(x: float, y: float, cx: float, cy: float, angle: float) -> tuple[float, float]:
"""Rotate point around center."""class Vec2:
"""2D vector class with mathematical operations."""
def __init__(self, x: float = 0, y: float = 0):
"""Create 2D vector."""
x: float
y: float
def __add__(self, other: 'Vec2') -> 'Vec2':
"""Vector addition."""
def __sub__(self, other: 'Vec2') -> 'Vec2':
"""Vector subtraction."""
def __mul__(self, scalar: float) -> 'Vec2':
"""Scalar multiplication."""
def dot(self, other: 'Vec2') -> float:
"""Dot product."""
def length(self) -> float:
"""Vector magnitude."""
def normalize(self) -> 'Vec2':
"""Normalized vector."""
class Vec3:
"""3D vector class."""
def __init__(self, x: float = 0, y: float = 0, z: float = 0):
"""Create 3D vector."""
x: float
y: float
z: floatdef rand_in_rect(rect: arcade.types.Rect) -> tuple[float, float]:
"""Random point within rectangle."""
def rand_in_circle(center_x: float, center_y: float, radius: float) -> tuple[float, float]:
"""Random point within circle."""
def rand_on_circle(center_x: float, center_y: float, radius: float) -> tuple[float, float]:
"""Random point on circle circumference."""
def rand_angle_360_deg() -> float:
"""Random angle 0-360 degrees."""
def rand_vec_magnitude(angle: float, lo_magnitude: float, hi_magnitude: float) -> tuple[float, float]:
"""Random vector with specified angle and magnitude range."""# Color type definitions
RGB = tuple[int, int, int]
RGBA = tuple[int, int, int, int]
RGBOrA = RGB | RGBA
class Color:
"""Color utility class with conversion methods."""
def __init__(self, r: int, g: int, b: int, a: int = 255):
"""Create color from RGBA values."""
r: int
g: int
b: int
a: int
@classmethod
def from_hex_string(cls, hex_string: str) -> 'Color':
"""Create color from hex string (e.g., '#FF0000')."""
def to_hex_string(self) -> str:
"""Convert to hex string."""
def to_tuple(self) -> tuple[int, int, int, int]:
"""Convert to RGBA tuple."""
# Common colors
BLACK: Color = (0, 0, 0, 255)
WHITE: Color = (255, 255, 255, 255)
RED: Color = (255, 0, 0, 255)
GREEN: Color = (0, 255, 0, 255)
BLUE: Color = (0, 0, 255, 255)# Point types
Point = tuple[float, float]
Point2 = tuple[float, float]
Point3 = tuple[float, float, float]
PointList = list[Point]
# Rectangle classes
class Rect:
"""General rectangle class."""
def __init__(self, x: float, y: float, width: float, height: float):
"""Create rectangle."""
x: float
y: float
width: float
height: float
def contains_point(self, x: float, y: float) -> bool:
"""Check if point is inside rectangle."""
def intersects(self, other: 'Rect') -> bool:
"""Check if rectangles intersect."""
class LRBT:
"""Rectangle defined by left, right, bottom, top."""
def __init__(self, left: float, right: float, bottom: float, top: float):
"""Create LRBT rectangle."""
left: float
right: float
bottom: float
top: float
class LBWH:
"""Rectangle defined by left, bottom, width, height."""
def __init__(self, left: float, bottom: float, width: float, height: float):
"""Create LBWH rectangle."""
left: float
bottom: float
width: float
height: floatimport arcade
import arcade.math
# Create vectors
velocity = arcade.math.Vec2(5.0, 3.0)
position = arcade.math.Vec2(100.0, 200.0)
# Vector operations
new_position = position + velocity
distance = velocity.length()
direction = velocity.normalize()
# Angle calculations
angle = arcade.get_angle_degrees(0, 0, 100, 100) # 45 degrees
rotated_point = arcade.rotate_point(10, 0, 0, 0, 90) # (0, 10)
# Interpolation
start_pos = (0, 0)
end_pos = (100, 100)
half_way = arcade.lerp_2d(start_pos, end_pos, 0.5) # (50, 50)Install with Tessl CLI
npx tessl i tessl/pypi-arcade