Helpers
This module contains a mishmash of stuff that didn’t fit anywhere else.
- quest.helpers.tint(color, ratio=0.25)[source]
Creates a tint of a color by scaling it toward pure white.
- Parameters
color (int, int, int) – The base color.
ratio (float) – A value between 0 and 1. 0 would have no effect; 1 would be pure white.
- quest.helpers.shade(color, ratio=0.25)[source]
Creates a shade of a color by scaling it toward pure black.
- Parameters
color (int, int, int) – The base color.
ratio (float) – A value between 0 and 1. 0 would have no effect; 1 would be pure black.
- class quest.helpers.Direction(value)[source]
Direction lets you talk about directions like Direction.DOWN, Direction.UPLEFT or using compass directions such as Direction.NE.
- classmethod from_vector(vector, diagonal=True)[source]
Converts an (x, y) tuple into a direction.
>>> Direction.from_vector((-1, 0)) Direction.LEFT >>> Direction.from_vector((0.4, 0.6)) Direction.UPRIGHT
- Parameters
vector (float, float) – An (x, y) tuple.
diagonal (bool) – Whether to include diagonal directions. Defaults to True.
- Returns
A Direction.
- is_diagonal()[source]
Returns whether the Direction is diaognal.
>>> Direction.NW.is_diagonal() True
- turn_clockwise()[source]
Returns the direction 90 degrees clockwise. Only supports cardinal directions.
- class quest.helpers.SpriteListList(sprite_lists)[source]
Allows multiple SpriteLists to be treated as if they were a single SpriteList.
- quest.helpers.tileset_to_collection(image_path, tile_size, output_dir, name='tileset', create_tsx=True)[source]
Splits a tileset image into separate files.
Quest relies on Arcade, which only works with collections of images. A lot of game art is provided as a single tile image. This function can help split it out.
- class quest.helpers.SimpleInkParser[source]
Parses a simple subset of Ink syntax into a JSON-like data structure.
The ink must meet the following constraints:
Must be valid Ink.
All content must be in a knot. Knots must be delimited with three equal signs on either side of the knot name.
The only syntax allowed is knot declarations, sticky choices (+) and diverts (->). Diverts are only allowed following a sticky choice.
- parse(ink)[source]
Reads a story written in a subset of Ink syntax (described above) and returns a data structure of content and choices, also described above.
- parse_knot_ink(line_num, ink)[source]
Reads lines of code in a knot and returns a list of content and a dict of options.