Mind.Orientation

Classes, methods and functions marked with * aren’t for usual cases, they are made to help to the rest of the library.

Part of library for maps and points in map.

exception Mind.Orientation.MapError(x, y, max_x, max_y, min_x, min_y)[source]

Exception for points outside the map.*

class Mind.Orientation.MAP(width, height, m_width=0, m_height=0)[source]

Basic map class.

Parameters:
  • width (int) – width of map
  • height (int) – height of map
  • m_width (int) – width on negative side
  • m_height (int) – height on negative side
add_obj(obj)[source]

Function that adds object(point, rect...) to map.*

at(x, y)[source]

Return generator of all items in map on x, y coordinates.

Parameters:
  • x (int) – x position of coordinate
  • y (int) – y position of coordinate
Returns:

iterator of all objects on that coordinates or None

class Mind.Orientation.point(x, y, Map, description='Unknown', quiet=False)[source]

Basic point class.

Parameters:
  • x (int) – x position of point
  • y (int) – y position of point
  • Map (MAP) – map on which will point be added
  • description (str) – point description
  • quiet (bool) – if True won’t appear on map
distance(other)[source]

Calculates distance between this and given point.

Parameters:other – other point
Returns:distance between this and other point
get_xy()[source]

Returns point’s x and y.

Returns:tuple of two integers (x and y)
class Mind.Orientation.line(points, Map, description='Unknown', quiet=False, from_line_seg=False)[source]

Basic line class.

Parameters:
  • points (tuple) – tuple of two points on line
  • Map (MAP) – Map on which will line be added
  • description (str) – line description
  • quiet (bool) – if True won’t appear on map
  • from_line_seg (bool) – do not use (helps to the library)
get_angle()[source]

Returns line angle.

Returns:smallest angle in relation to y-axis
class Mind.Orientation.line_seg(points, Map, description='Unknown', quiet=False, from_line=False)[source]

Bacis line segment class.

Parameters:
  • points (tuple) – tuple of end points on line
  • Map (MAP) – Map on which will line segment be added
  • description (str) – line description
  • quiet (bool) – if True won’t appear on map
  • from_line (bool) – do not use (helps to the library)
get_angle()[source]

Returns line angle.

Returns:smallest angle in relation to y-axis
Mind.Orientation.q_points(x1, y1, x2, y2, Map)[source]

Returns points for line and line_seg.

Parameters:
  • x1 (int) – x coordinate for first point
  • y1 (int) – y coordinate for first point
  • x2 (int) – x coordinate for second point
  • y2 (int) – y coordinate for second point
Returns:

tuple of two point

class Mind.Orientation.ray(start_p, some_p, Map, description='Unknown', quiet=False)[source]

Basic ray class.

Parameters:
  • start_p (point) – starting point of ray
  • some_p (point) – any other point on ray
  • Map (MAP) – Map on which will line segment be added
  • description (str) – ray description
  • quiet (bool) – if True won’t appear on map
class Mind.Orientation.direction(point, angle, Map, description='Unknown', quiet=False)[source]

Basic direction class.

Parameters:
  • point (point) – point of direction
  • angle (int) – direction angle
  • Map (MAP) – Map on which will direction be added
  • description (str) – direction description
  • quiet (bool) – if True won’t appear on map
get_pos(distance)[source]

Gets point of direction with given distance.

Parameters:distance (int) – how far from direction point is
Returns:point on distance far away from direction point
Return type:point
move(distance)[source]

‘Moves’ directions point.

Parameters:distance (int) – how far will direction be moved
set_angle(angle)[source]

Sets new angle.

Parameters:angle (int) – new angle for direction
get_angle()[source]

Returns direction angle.

Returns:direction angle
ch_angle(change)[source]

Changes angle for given value.

Parameters:change (int) – how much will angle be increased
class Mind.Orientation.group_of_points(Map, description='Unknown', *points, quiet=False)[source]

Class for group of points.

Parameters:
  • Map (MAP) – map on which will group be added
  • description (str) – group description
  • points – group points
  • quiet (bool) – if True won’t appear on map
at(x, y)[source]

Return generator of all points in group on x, y coordinates.

Parameters:
  • x (int) – x coordinate of position
  • y (int) – y coordinate of position
Returns:

iterator of all points on that position

class Mind.Orientation.rect(x, y, width, height, Map, description='Unknown', quiet=False)[source]

Basic map rect class.

Parameters:
  • x (int) – x position of rect
  • y (int) – y position of rect
  • width (int) – rect width
  • height (int) – rect height
  • Map (MAP) – map on which will rect be added
  • description (str) – rect description
  • quiet (bool) – if True won’t appear on map
at(x, y)[source]

Test if point is in rect.*

collide(other)[source]

Tests colliding with given rect.

Parameters:other (rect) – other rect
Returns:list of four integers (how much are they colliding), first for right, second for down...
touch(other)[source]

Tests touching with other rect.

Parameters:other (rect) – other rect
Returns:list of four booleans (are rects touching), first for right, second for down...
class Mind.Orientation.ext_obj(obj, *args, **kwargs)[source]

Extended object class.

Parameters:
  • obj (type) – object which will be extended
  • args – object extended arguments
  • kwargs – object extended dictionary arguments
class Mind.Orientation.tiled_map(name, r_decoder={'p': <class 'Mind.Orientation.point'>}, a_decoder={'P': <class 'Mind.Orientation.point'>})[source]

Class for map in tiled.

Parameters:
  • name (str) – file name
  • r_decoder (dict) – ‘decodes’ objects from map into given objects
  • a_decoder (dict) – same as r_decoder, but uses tiledtmxloader object as input
set_screen(screen)[source]

Sets screen (pygame) on which will map be blited.

Parameters:screen (pygame.Surface) – screen on which will map be blitted
set_camera_pos(x, y, edge=True)[source]

Sets camera position (centre).

Parameters:
  • x (int) – x position of centre
  • y (int) – y position of centre
  • edge (bool) – if True won’t be outside the screen
get_camera_pos()[source]

Returns camera position.

Returns:tuple with x and y position
blit()[source]

Blits map (on setted screen).

clone_obj(key, key_type='name')[source]

Returns list of all objects with given name.

Parameters:key (str) – name of searching object/s
Para str key_type:
 for now unimportant (might be in next version
set_edge(width, height)[source]

Sets edge of map.

Parameters:
  • width (int) – width of new map
  • height (int) – height of new map
offset(x, y)[source]

Sets how off map is.

Parameters:
  • x (int) – starting x of map
  • y (int) – starting y of map
class Mind.Orientation.map_obj(x, y, Map, picture, name='Unknown')[source]

Basic Map object.

Parameters:
  • x (int) – x position of object
  • y (int) – y position of object
  • Map (tiled_map) – object map
  • picture (pygame.Surface) – object picture (which will be blitted)
  • name (str) – object name
blit()[source]

Blits object picture on Map screen.*

get_blit()[source]

Returns position on which picture would be blitted.

set_position(x, y)[source]

Sets position of object.

Parameters:
  • x (int) – sets centre x position of map
  • y (int) – sets centre y position of map
move(x, y)[source]

Moves object.

Parameters:
  • x (int) – x move
  • y (int) – y move
class Mind.Orientation.moving_map(name, x, y, screen, edge=True, r_decoder={'p': <class 'Mind.Orientation.point'>}, a_decoder={'P': <class 'Mind.Orientation.point'>})[source]

Map in which moving is very easy.

Parameters:
  • name (str) – file name
  • x (int) – initial x position
  • y (int) – initial y position
  • r_decoder (dict) – ‘decodes’ objects from map into given objects
  • a_decoder (dict) – same as r_decoder, but uses tiledtmxloader object as input
set_position(x, y)[source]

Sets position of map centre object.

Parameters:
  • x (int) – x position of centre object
  • y (int) – y position of centre object
get_position()[source]

Returns ‘centre object’ position.

Parameters:
  • x (int) – sets centre x position of map
  • y (int) – sets centre y position of map
move(x, y)[source]

Moves ‘centre object’.

Parameters:
  • x (int) – x move
  • y (int) – y move

Warning

tiled_map and classes after will be initialized only if tiledtmxloader can be initialized!

Previous topic

Mind.Knowledge

Next topic

Mind.Imagination

This Page