levelz¶
Python bindings & API for the LevelZ File Format
Submodules¶
Classes¶
Represents the scroll direction of a 2D Level. |
|
Represents a LevelZ level. |
|
Represents a 2D Level. |
|
Represents a 3D Level. |
|
Represents a Game Dimension. |
|
Represents a Game Coordinate. |
|
Represents a 2-Dimensional Coordinate. |
|
Represents a 3-Dimensional Coordinate. |
|
Represents a Block in a Level. |
|
Utility Object for representing a Level Block and its Coordinate. |
Functions¶
|
Parses a Level from a string. Uses 'n' as the line separator. |
|
Parses a Level from a file. |
|
Parses a Level from a list of strings. |
Package Contents¶
- class levelz.Scroll¶
Bases:
enum.Enum
Represents the scroll direction of a 2D Level.
- NONE = 'none'¶
No Scrolling
- HORIZONTAL_LEFT = 'horizontal-left'¶
Horizontal Scrolling moving left
- HORIZONTAL_RIGHT = 'horizontal-right'¶
Horizontal Scrolling moving right
- VERTICAL_UP = 'vertical-up'¶
Vertical Scrolling moving up
- VERTICAL_DOWN = 'vertical-down'¶
Vertical Scrolling moving down
- class levelz.Level(dimension: levelz.coord.Dimension)¶
Represents a LevelZ level.
- _dimension: levelz.coord.Dimension¶
- _blocks: list[levelz.block.LevelObject] = []¶
- _headers: dict[str, object]¶
- property dimension¶
- Returns the Dimension of the Level.
- property blocks¶
- Returns an immutable copy of the blocks in the Level.
- property headers¶
- Returns an immutable copy of the headers in the Level.
- class levelz.Level2D(headers: dict[str, object] = {}, blocks: list[levelz.block.LevelObject] = [])¶
Bases:
Level
Represents a 2D Level.
- property scroll¶
- Returns the Scroll of the Level.
- property spawn¶
- Returns the spawn point of the Level.
- class levelz.Level3D(headers: dict[str, object] = {}, blocks: list[levelz.block.LevelObject] = [])¶
Bases:
Level
Represents a 3D Level.
- property spawn¶
- Returns the spawn point of the Level.
- class levelz.Dimension¶
Bases:
enum.Enum
Represents a Game Dimension.
- TWO = 2¶
Represents a 2D Plane.
- THREE = 3¶
Represents a 3D Space.
- property is2D¶
- Returns True if the Dimension is 2D.
- property is3D¶
- Returns True if the Dimension is 3D.
- __str__()¶
Return str(self).
- __eq__(other)¶
Return self==value.
- class levelz.Coordinate¶
Represents a Game Coordinate.
- abstract property magnitude¶
Return the magnitude of the coordinate.
- abstract property dimension¶
Return the dimension of the coordinate.
- class levelz.Coordinate2D(x: float, y: float)¶
Bases:
Coordinate
Represents a 2-Dimensional Coordinate.
- x: float = 0¶
The x-coordinate of the 2D Coordinate.
- y: float = 0¶
The y-coordinate of the 2D Coordinate.
- property magnitude¶
- Return the magnitude of the coordinate.
- property dimension¶
- Return the dimension of the coordinate.
- __str__()¶
Return str(self).
- __eq__(other)¶
Return self==value.
- static from_string(s: str)¶
Parses a string to create a 2D Coordinate.
- Parameters:
s (str) – The string to parse.
- Returns:
The 2D Coordinate.
- Return type:
- class levelz.Coordinate3D(x: float, y: float, z: float)¶
Bases:
Coordinate
Represents a 3-Dimensional Coordinate.
- x: float = 0¶
The x-coordinate of the 3D Coordinate.
- y: float = 0¶
The y-coordinate of the 3D Coordinate.
- z: float = 0¶
The z-coordinate of the 3D Coordinate.
- property magnitude¶
- Return the magnitude of the coordinate.
- property dimension¶
- Return the dimension of the coordinate.
- __str__()¶
Return str(self).
- __eq__(other)¶
Return self==value.
- static from_string(s: str)¶
Parses a string to create a 3D Coordinate.
- Parameters:
s (str) – The string to parse.
- Returns:
The 3D Coordinate.
- Return type:
Coordiante3D
- class levelz.Block(name: str, properties: dict[str, object] = {})¶
Represents a Block in a Level.
- _name: str = ''¶
- _properties: dict[str, object]¶
- property name¶
- Returns the name of the Block.
- property properties¶
- Returns an immutable copy of the properties for the Block.
- __str__()¶
Return str(self).
- __eq__(other)¶
Return self==value.
- class levelz.LevelObject(block: Block | str, coordinate: levelz.coord.Coordinate | list[int | float])¶
Utility Object for representing a Level Block and its Coordinate.
- _coordinate: levelz.coord.Coordinate¶
- property block¶
- Returns the Block of the LevelObject.
- property coordinate¶
- Returns the Coordinate of the LevelObject.
- __str__()¶
Return str(self).
- __eq__(other)¶
Return self==value.
- levelz.parse_level(level: str)¶
Parses a Level from a string. Uses ‘n’ as the line separator.
- levelz.parse_file(file: str)¶
Parses a Level from a file.
- levelz.parse_lines(level: list[str])¶
Parses a Level from a list of strings.