game.utils.helpers

Helper functions and utilities.

Functions

distance(x1, y1, x2, y2)

Calculate distance between two points.

normalize_vector(x, y)

Normalize a vector to unit length.

clamp(value, min_val, max_val)

Clamp a value between min and max.

interpolate(start, end, t)

Linear interpolation between start and end.

point_in_rect(point, rect)

Check if a point is inside a rectangle.

create_gradient_surface(width, height, start_color, ...)

Create a gradient surface.

format_time(seconds)

Format time in MM:SS format.

Module Contents

game.utils.helpers.distance(x1, y1, x2, y2)[source]

Calculate distance between two points.

game.utils.helpers.normalize_vector(x, y)[source]

Normalize a vector to unit length.

game.utils.helpers.clamp(value, min_val, max_val)[source]

Clamp a value between min and max.

game.utils.helpers.interpolate(start, end, t)[source]

Linear interpolation between start and end.

game.utils.helpers.point_in_rect(point, rect)[source]

Check if a point is inside a rectangle.

game.utils.helpers.create_gradient_surface(width, height, start_color, end_color)[source]

Create a gradient surface.

game.utils.helpers.format_time(seconds)[source]

Format time in MM:SS format.