image_loader module

class image_loader.TetrominoImageLoader

Bases: object

A loader class for accessing Tetromino images based on piece IDs and their sticky state.

This class provides a way to dynamically generate the path to image files for different Tetromino pieces based on their ID. The piece ID directly corresponds to a specific Tetromino shape and rotation, and the sticky state is indicated by a separate boolean flag.

piece_info

A mapping from piece IDs to their corresponding names and available rotations.

Type:

dict

get_image_path(piece_id, sticky=True)

Generates the file path to the image corresponding to a given Tetromino piece ID and its sticky state.

Parameters:
  • piece_id (int) – The ID of the Tetromino piece (0 – 19).

  • sticky (bool) – Indicates if the image should represent a sticky state. Defaults to True.

Returns:

The file path to the Tetromino piece’s image.

Return type:

str

Raises:

ValueError – If the piece_id does not correspond to any known piece configuration.