Positions -> Position
Contents
Positions -> Position#
- class miniworldmaker.positions.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
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.
distance_to
(other)direction_to
(other)direction_to
(other)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()
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
Position
__new__
(_cls, x, y)Create new instance of Position(x, y)
Inherited from
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:
_abc_impl
Inherited from
Position
_fields
_field_defaults
Inherited from
PositionBase
_abc_impl
Inherited from
ABC
_abc_impl
Private Methods:
Inherited from
Position
- angle_to(other)#
- 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
- 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
- to_int()[source]#
Transforms both coordinates of a position to integers :return: Tuple (x,y) , x and y are integers.