BoardPositions

BoardPositions

BoardPosition

class miniworldmaker.board_positions.board_position.Position(x, y)[source]

A Position Object represents a position on a Board.

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

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

Public Data Attributes:

Inherited from : py: class:Position

x

Alias for field number 0

y

Alias for field number 1

Public Methods:

__str__()

Return str(self).

from_vector(vector)

Transforms a miniworldmaker-Vector object to a position.

from_board_coordinates(position)

Transforms board-coordinates to position

create(value)

Creates a board position from value

from_pixel(position)

Transforms pixel-coordinates to position by calling board.get_from_pixel()

to_pixel_from_tile()

Transforms position to pixel-coordinates by calling board.to_pixel() :return:

add(x, y)

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

__add__(other)

Adds two board coordinates (or board-coordinate and vector)

__sub__(other)

__neg__()

to_int()

Transforms both coordinates of a position to integers :return: Tuple (x,y) , x and y are integers.

is_close(other[, error])

Is a position close to another position

up(value)

down(value)

left(value)

right(value)

Inherited from : py: class:Position

__new__(_cls, x, y)

Create new instance of Position(x, y)

__repr__()

Return a nicely formatted representation string

__getnewargs__()

Return self as a plain tuple.

Inherited from : py: class:tuple

__repr__()

Return a nicely formatted representation string

__hash__()

Return hash(self).

__getattribute__(name, /)

Return getattr(self, name).

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.

__iter__()

Implement iter(self).

__len__()

Return len(self).

__getitem__(key, /)

Return self[key].

__add__(other)

Adds two board coordinates (or board-coordinate and vector)

__mul__(value, /)

Return self*value.

__rmul__(value, /)

Return value*self.

__contains__(key, /)

Return key in self.

__getnewargs__()

Return self as a plain tuple.

index(value[, start, stop])

Return first index of value.

count(value, /)

Return number of occurrences of value.

__class_getitem__

See PEP 585

Private Data Attributes:

Inherited from : py: class:Position

_fields

_field_defaults

Private Methods:

Inherited from : py: class:Position

_make(iterable)

Make a new Position object from a sequence or iterable

_replace(**kwds)

Return a new Position object replacing specified fields with new values

_asdict()

Return a new dict which maps field names to their values.


add(x, y)[source]

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

Returns:

The new Position

classmethod create(value)[source]

Creates a board position from value

If value is … * Tuple: A new Position-object will be created * Position: The position object itself is returned * pygame.Rect: The position is created from topleft corner of Rect

down(value)[source]
classmethod from_board_coordinates(position)[source]

Transforms board-coordinates to position

Parameters:

position

Returns:

The Position

classmethod from_pixel(position)[source]

Transforms pixel-coordinates to position by calling board.get_from_pixel()

Parameters:

position (Tuple) –

Returns:

classmethod from_vector(vector)[source]

Transforms a miniworldmaker-Vector object to a position. :type vector: Vector :param vector: The vector :return: The Position

is_close(other, error=1)[source]

Is a position close to another position

Parameters:
Returns:

If x-other.x < error and y-other.y < error, is_close() returns True

left(value)[source]
right(value)[source]
to_int()[source]

Transforms both coordinates of a position to integers :return: Tuple (x,y) , x and y are integers.

to_pixel_from_tile()[source]

Transforms position to pixel-coordinates by calling board.to_pixel() :return:

up(value)[source]