Mind.Orientation

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

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

Exception for points outside the map.*

class Mind.Orientation.MAP(width, height)[source]

Basic map class.

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.

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

Basic point class.

distance(other)[source]

Calculates distance between this and given point.

get_xy()[source]

Returns point’s x and y.

class Mind.Orientation.line(points, Map, description='Unknown', quiet=False, from_line_seg=False)[source]

Basic line class.

get_angle()[source]

Returns line smallest angle (0-90).*

get_f_angle(p_index)[source]

Returns full line angle (0-360).

perpend(point, quiet=False)[source]

Returns perpendicular that goes through given point.

collide(L)[source]

Returns point of intersection of lines.

class Mind.Orientation.line_seg(points, Map, description='Unknown', quiet=False, from_line=False)[source]

Basic line segment class.

get_angle()[source]

Returns line smallest angle(0-90).*

get_f_angle(p_index)[source]

Returns full line angle (0-360).

Mind.Orientation.q_points(x1, y1, x2, y2, Map)[source]

Returns points for line and line_seg.

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

Basic ray class.

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

Basic direction class.

get_pos(distance)[source]

Gets point of direction with given distance.

move(distance)[source]

‘Moves’ directions point.

set_angle(angle)[source]

Sets new angle.

get_angle()[source]

Returns direction angle.

ch_angle(change)[source]

Changes angle for given value.

line(quiet=False)[source]

Returns direction’s line.

class Mind.Orientation.group_of_points(Map, description='Unknown', *points, quiet=False)[source]

Class for group of points.

at(x, y)[source]

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

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

Basic map rect class.

at(x, y)[source]

Test if point is in rect.*

collide(other)[source]

Tests colliding with given rect.

touch(other)[source]

Tests touching with other rect.

points(quiet=True)[source]

Returns rect’s points.

get_xy()[source]

Returns rect’s coordinates.

class Mind.Orientation.circle(centre, radius, Map, description='Unknown', quiet=False)[source]

Basic circle class.

distance(l)[source]

Returns distance between centre and line.

class Mind.Orientation.element(name, props, Map)[source]

Basic tilemap element class.*

class Mind.Orientation.layer(name, props, mapping, Map)[source]

Basic tilemap layer (Tile Layer) class.*

set_pos(x, y)[source]

Sets position of layer.*

blit()[source]

Blits layer.*

class Mind.Orientation.Object(name, Type, props, Map, obj)[source]

Basic tilemap object class.*

class Mind.Orientation.map_obj(name, Type, props, picture, Map, obj)[source]

Blitable tilemap object class.

blit()[source]

Blits object.*

get_blit()[source]

Returns where object should be blitted.*

set_position(x, y)[source]

Sets object position.

move(x, y)[source]

Moves object.

class Mind.Orientation.Subject(name, Type, props, picture, Map, obj)[source]

Basic centre tilemap object class (subclass of map_obj).

set_position(x, y)[source]

Sets object position.

move(x, y)[source]

Moves object.

class Mind.Orientation.objectgroup(name, props, objects, Map)[source]

Basic tilemap objectgroup (Object Layer) class.

blit()[source]

Blits all objects in objectgroup.*

class Mind.Orientation.image(name, tile_x, tile_y, first, screen)[source]

Basic tileset class.*

Index(index)[source]

Returns firstindex if index is in tileset else 0.*

blit(pos, index)[source]

Blits image on index at position pos.*

class Mind.Orientation.visual_map(x, y, layers=True, path='', decode=[{}, {}, {}], tilesize=(), images={}, else_=[<class 'Mind.Orientation.layer'>, <class 'Mind.Orientation.objectgroup'>, <class 'Mind.Orientation.Object'>], gid_point=True, gid_line=True, size_in_tiles=False)[source]

Basic class for game map.

Parameters:
  • x (int) – width of map
  • y (int) – height of map
  • layers (bool) – does map have layers
  • path (str) – path to all map images
  • decode (list of dicts) – decoding; first dict is for layers, second for objectgroup and third for object
  • tilesize (tuple) – size of each tile (needed only if layers are used)
  • images (dict) – dictionary containing images paths and their nickname (used in write_on)
  • else (list) – default decoding; first for layer, second for objectgroup, third for object
  • gid_point (bool) – if True object’s obj will be point if rect doesn’t have width and height
  • gid_line (bool) – if True object’s obj will be line if rect doesn’t have width or height
  • size_in_tiles (bool) – is x and y measured in tiles
set_camera_pos(x, y, pos=(50, 50), edge=True)[source]

Sets camera position.

Parameters:
  • x (int) – x position of point
  • y (int) – y position of point
  • pos (tuple) – point of screen in percentage
  • edge (bool) – if True won’t be outside the screen
get_camera_pos(pos=(50, 50))[source]

Gets camera position.

Parameters:pos (tuple) – point of screen in percentage
blit()[source]

Blits map and it’s all objects to the screen.

create_objectgroup(name, props={}, objects=[], **rest)[source]

Creates map’s objectgroup.

Parameters:
  • name (str) – objectgroup name
  • props (dict) – properties of objectgroup
  • objects (list) – objects that belong to objectgroup
  • rest – other objectgroup parameters
load_objectgroup(xml_obj)[source]

Loads objectgroup from xml element.*

Parameters:xml_obj – element from which objectgroup is loaded
assign_object(objgroup, obj)[source]

Assigns object to particular objectgroup.*

Parameters:
  • objgroup (str) – name of the objectgroup
  • obj – object which will be assigned
create_object(objgroup, name, Type, props={}, obj=None, **rest)[source]

Creates map object and assigns it to particular objectgroup.

create_layer(name, props={}, **rest)[source]

Creates map layer

Parameters:
  • name (str) – layer name
  • props (dict) – layer properties
  • rest – other layer parameters
load_layer(xml_obj)[source]

Loads objectgroup from xml element.*

Parameters:xml_obj – element from which layer is loaded
create_tileset(img, name)[source]

Creates map tileset.

Parameters:
  • img (str) – path to tileset image
  • name (str) – tileset name
write_on(pos, layer, num, pic=None, mul_pos=False)[source]

Changes map layer.

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

Returns list of all objects with given parameter.

Parameters:
  • key (str) – parameter of searching object/s
  • key_type (str) – name, group or type; what key means.
set_edge(width, height)[source]

Sets map edge.

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

Sets map offset.

Parameters:
  • x (int) – starting x of map
  • y (int) – starting y of map
class Mind.Orientation.tiled_map(name, decode=[{}, {}, {}], else_=[<class 'Mind.Orientation.layer'>, <class 'Mind.Orientation.objectgroup'>, <class 'Mind.Orientation.Object'>], gid_point=True, gid_line=True)[source]

Basic class for map in Tiled.

Parameters:
  • name (str) – file name
  • decode (list of dicts) – decoding; first dict is for layers, second for objectgroup and third for object
  • else (list) – default decoding; first for layer, second for objectgroup, third for object
  • gid_point (bool) – if True object’s obj will be point if rect doesn’t have width and height
  • gid_line (bool) – if True object’s obj will be line if rect doesn’t have width or height
reset_screen()[source]

Resets map’s screen (should be executed if screen wasn’t defined before)

class Mind.Orientation.moving_map(name, x, y, decode=[{}, {}, {}], else_=[<class 'Mind.Orientation.layer'>, <class 'Mind.Orientation.objectgroup'>, <class 'Mind.Orientation.Object'>], gid_point=True, gid_line=True)[source]

Subclass of tiled_map for easier moving.

Parameters:
  • name (str) – file name
  • x (int) – map centre object x
  • y (int) – map centre object y
  • decode (list of dicts) – decoding; first dict is for layers, second for objectgroup and third for object
  • else (list) – default decoding; first for layer, second for objectgroup, third for object
  • gid_point (bool) – if True object’s obj will be point if rect doesn’t have width and height
  • gid_line (bool) – if True object’s obj will be line if rect doesn’t have width or height
set_position(x, y, pos=(50, 50), edge=True)[source]

Sets centre object position

Parameters:
  • x (int) – x position of centre object
  • y (int) – y position of centre object
  • pos (tuple) – point of screen in percentage
  • edge (bool) – if True won’t be outside the screen
get_position()[source]

Returns centre object coordinates.

Returns:centre x and y
Return type:tuple
move(hor, ver, pos=(50, 50), edge=True)[source]

Moves centre object.

Parameters:
  • hor (int) – horizontal movement (positive for right, negative for left)
  • ver (int) – vertical movement (positive for down, negative for up)
  • pos (tuple) – point of screen in percentage
  • edge (bool) – if True won’t be outside the screen