BoardPositions, Lines and Rectangles

BoardPosition

class miniworldmaker.board_positions.board_position.BoardPosition[source]

A BoardPosition Object represents a position on a Board.

As a subclass of namedtuple, BoardPosition is for performance reasons not mutable.

On a tiled board, the BoardPosition does not describe pixels but tiles coordinates.

add(x, y)[source]

Adds x and y to the board positions x and y coordinate

Returns: The new BoardPosition

borders()[source]

Gets borders of a board-position

Returns:

color()[source]

Returns the board-color at the current board-position

Returns: The board-color at the current board position as tuple with r,g,b value and transparency (e.g. (255, 0, 0, 100)

down(value: int)[source]

Gets the board position below the actual board-position

Parameters

value – the number of fields below the actual position

Returns

A new BoardPosition

classmethod from_float(float_position: tuple)[source]

Gets a board_position from float and convert the float values into integer. If you don’t want the position converted into a integer-value, use from_tuple

Parameters

float_position – Float position

Returns:

classmethod from_pixel(position: tuple)[source]

Gets the board_position from pixel coordinates

If the board is a pixel-board, pixel-position and board_position are the same

Parameters

position – The board position as pixel-coordinates

Returns:

classmethod from_rect(rect: miniworldmaker.board_positions.board_rect.BoardRect)[source]

Gets a board position from rect. The BoardPosition is the center-position of the rectangle

Parameters

rect – The rectangle

Returns:

classmethod from_tuple(tpl: tuple)[source]

Gets a board position from tuple.

Parameters

tpl – The tuple

Returns:

is_on_board()[source]

Checks if BoardPosition is on board

Returns

True, if Position is on board.

left(value: int)[source]

Gets the board position left of the the actual board-position

Parameters

value – the number of fields left of the the actual position

Returns

A new BoardPosition

near(other, distance)[source]

Checks if two Board-Positions are near each other

Parameters
  • other – A second Board-Position.

  • distance – The size of the environment in which 2 positions are called “near”.

Returns

True, If the Positions are near each other.

right(value: int)[source]

Gets the board position right of the actual board-position

Parameters

value – the number of fields right of the actual position

Returns

A new BoardPosition

to_pixel() → tuple[source]
Converts board_position to pixel-coordinates.
  • If the board is a PixelBoard, these are the same values.

  • If the board is a TiledBoard, the top-left corner of a tile is returned.

Returns: The Top-Left Pixel of current board-position

to_rect(rect: pygame.Rect = None) → miniworldmaker.board_positions.board_rect.BoardRect[source]

Converts a board position into a rect. The board_position is at the top-left corner of the rect.

Parameters
  • rect – The rect dimensions (x and y coordinates are ignored. If rect is None,

  • board.tile_size is used instead. (the) –

Returns: The rect at the given position

to_tuple()[source]

Converts board_position into a tuple (x, y)

Returns: The boar

up(value: int)[source]

Gets the board position above the actual board-position

Parameters

value – the number of fields above the actual position

Returns

A new BoardPosition

BoardRect

class miniworldmaker.board_positions.board_rect.BoardRect(*args, **kwargs)[source]
borders()[source]

Gets all borders the rect ist touching.

Returns: A list of borders as strings: “left”, “bottom”, “right”, or “top”