data module

Data package.

It holds data-related modules needed to determine how the game will behaved and what it should do when it does.

data.data_translate

Module name: data_translate

This module manages the translation of all data constants (states, properties, etc.)

class game.data.data_translate.DataTranslate

Bases: object

Class for translating all data constants.

static translate_data()

Call all data translate methods to update data constants.

data.items

Items package.

data.items.item

Module name: item

This module defines the item object and its properties.

class game.data.items.item.Item(x: int = 0, y: int = 0, tooltip_name: str = '')

Bases: object

Class for creating a usable item.

DEFAULT_ATLAS: str = '/home/docs/checkouts/readthedocs.org/user_builds/tile-game/checkouts/latest/game/assets/items.png'
get_durability() int

Return the durability of the item.

get_strength() int

Return the strength of the item.

get_tooltip_name() str

Return the tooltip name of the item.

get_xy() tuple[int, int]

Return the texture coordinates of the item.

set_durability(durability: int) Self

Set the durability of the item, then return the item itself.

set_strength(strength: int) Self

Set the strength of the item, then return the item itself.

set_tooltip_name(tooltip_name: str) Self

Set the tooltip name of the item, then return the item itself.

set_xy(x: int, y: int) Self

Set the texture coordinates of the item, then return the item itself.

data.items.item_types

Module name: item_types

This module defines the item types. Need I say more?

class game.data.items.item_types.ItemTypes

Bases: object

Class for regrouping items into different categories.

TOOLS: tuple[Items] = (<game.data.items.item.Item object>,)
WEAPONS: tuple[Items] = (<game.data.items.item.Item object>,)

data.items.items

Module name: items

This module defines the different game items.

class game.data.items.items.Items

Bases: object

Class for creating a collection of items.

AIR: Item = <game.data.items.item.Item object>
GUN: Item = <game.data.items.item.Item object>
SHOVEL: Item = <game.data.items.item.Item object>
static translate()

Translate the item tooltips.

data.keys

Module name: keys

This module defines all the hotkeys, linked to specific in-game actions.

class game.data.keys.Keys

Bases: object

Class for regrouping all the keys associated to different game actions.

data.properties

Properties package.

Properties are just constants that define most of the game’s behaviour.

data.properties.camera_properties

Module name: camera_properties

This module defines the camera properties.

class game.data.properties.camera_properties.CameraProperties

Bases: object

Class for camera properties.

SPEED = 350
VELOCITY_START_DURATION: float = 0.25
VELOCITY_STOP_DURATION: float = 0.5

data.properties.game_properties

Module name: game_properties

This module defines the main game properties.

class game.data.properties.game_properties.GameProperties

Bases: object

Class for the main game properties.

APP_NAME = 'untitled game'
APP_VER = '0.0.2a'
KEY_DELAY = 500
KEY_INTERVAL = 25
LOGGER_DELAY = 0.5

data.properties.gui_properties

Module name: gui_properties

This module defines the GUI properties.

class game.data.properties.gui_properties.GuiProperties

Bases: object

Class for GUI properties. Duration constants are in seconds.

CHECKBOX_CHECK_ANIM_DURATION = 0.2
SNOW_PARTICLE_DENSITY = (20, 10)
TITLE_ANIM_DURATION = 2.0

data.properties.item_properties

Module name: item_properties

This module defines the item properties.

class game.data.properties.item_properties.ItemProperties

Bases: object

Class for item properties.

ITEM_SIZE: int = 32

data.properties.player_properties

Module name: player_properties

This module defines the player entity properties.

class game.data.properties.player_properties.PlayerProperties

Bases: object

Class for player properties.

MAX_PLAYER_NAME_SIZE = 16
SPEED = 350
SPEED_IN_LAVA = 116
SPEED_IN_WATER = 175
TEXTURE: str = '/home/docs/checkouts/readthedocs.org/user_builds/tile-game/checkouts/latest/game/assets/player.png'
VELOCITY_START_DURATION: float = 0.1
VELOCITY_STOP_DURATION: float = 0.25
VELOCITY_THRESHOLD: float = 0.0001

data.properties.screen_properties

Module name: screen_properties

This module defines the screen properties.

class game.data.properties.screen_properties.ScreenProperties

Bases: object

Class for screen properties.

ALPHA = 136
PRONOUNCED_ALPHA = 160

data.properties.server_properties

Module name: server_properties

This module defines the server properties.

class game.data.properties.server_properties.ServerProperties

Bases: object

Class for server properties.

DELAY_BEFORE_CLOSURE = 5.0
MAX_PLAYERS = 10
TICKS_PER_SECOND = 20

data.properties.tile_properties

Module name: tile_properties

This module defines the tile properties.

class game.data.properties.tile_properties.TileProperties

Bases: object

Class for tile properties.

TILE_ADJACENT_DUPLICATES_MAX = 36864
TILE_DAMAGE_DELAY_MAX = 8.0
TILE_DAMAGE_MAX = 127
TILE_RESISTANCE_MAX = 63
TILE_SIZE = 32
TILE_X_MAX = 7
TILE_Y_MAX = 7

data.properties.world_properties

Module name: world_properties

This module defines the world properties.

class game.data.properties.world_properties.WorldProperties

Bases: object

Class for world properties.

MAP_LARGE = 'Large'
MAP_MEDIUM = 'Medium'
MAP_SMALL = 'Small'
MAX_MAP_HEIGHT = 192
MAX_MAP_WIDTH = 192
MIN_MAP_HEIGHT = 64
MIN_MAP_WIDTH = 64
SKY_COLOUR = (140, 150, 235)
static translate()

Translate the world properties.

data.states

States package.

States are values that describe the condition that something is in. A server can be starting, a player can be moving left, a connection can time out. Those are all states. They don’t define behaviour but report behaviour.

data.states.connection_states

Module name: connection_states

This module defines the different states of a connection.

class game.data.states.connection_states.ConnectionStates

Bases: object

Connection states.

BADNAME = 6
BADTHEME = 9
DISCONNECTED = 5
ERROR = 10
GETDATA = -3
IDLE = -1
INVALID = 1
MAXIMUM = 7
NOROUTE = 4
PENDING = -2
REFUSED = 2
SERVFAIL = 8
SUCCESS = 0
TIMEOUT = 3

data.states.map_states

Module name: map_states

This module defines the different states of the map.

class game.data.states.map_states.MapStates

Bases: object

Map states.

GENMAP = 'GEN-MAP'
READY = 'READY'

data.states.mouse_states

Module name: mouse_states

This module defines the different states of the mouse.

class game.data.states.mouse_states.MouseStates

Bases: object

Mouse states.

LMB = 1
MMB = 2
RMB = 3
SCROLL_DOWN = 5
SCROLL_UP = 4

data.states.player_states

Module name: player_states

This module defines the different states of the player.

class game.data.states.player_states.PlayerStates

Bases: object

Player states.

MOVE_DOWN = 3
MOVE_LEFT = 0
MOVE_RIGHT = 2
MOVE_UP = 1

data.states.server_states

Module name: server_states

This module defines the different states of the server.

class game.data.states.server_states.ServerStates

Bases: object

Server states.

FAIL = 3
IDLE = 0
RUNNING = 2
STARTING = 1

data.structures

Structures package.

Structures are classes containing constants of size, position and other properties of different attributes of an object. They are used to build compressed packets that aim to be sent to and from the server.

TYPES OF SIZE CONSTANTS:

  • BIT_SIZE

    The bit size constant represents the size of a specific object attribute in bits. This means dividing the value by 8 is necessary to obtain a size in bytes.

  • BYTE_SIZE

    The byte size constant represents, as its name suggests, the size of a specific attribute in bytes.

The reason to having different types of sizes is based on how the “compact packets” are created. If they are created specifically utilising bit manipulation operators (<<, >>, &, |, ~, etc.), then bit size constants are required, as they are very precise. If they are created from direct int to byte conversion (using int.to_bytes() and int.from_bytes()), then the precision of the sizes become less important. Direct int - byte conversions are usually done on attributes that require more allocated memory and where precision becomes too tedious.

POSITION CONSTANTS:

The position constants are used to determine where the attributes will be located at in the “compact packet”. This is only used for packets that require precise bit manipulation in order to build.

STRUCTURES:

  • PLAYER STRUCTURE

    This contains all constants for player-related packets.

  • MAP STRUCTURE

    This contains all constants for map-related packets.

  • TILE STRUCTURE

    This contains all constants for tile-related packets.

data.structures.map_structure

Module name: map_structure

This module defines the byte (or data packet) structure for the world map.

class game.data.structures.map_structure.MapStructure

Bases: object

Byte structure for the map.

MAP_DTD_LEN_BYTE_SIZE = 2
MAP_HEIGHT_BYTE_SIZE = 1
MAP_TD_LEN_BYTE_SIZE = 3
MAP_WIDTH_BYTE_SIZE = 1

data.structures.player_structure

Module name: player_structure

This module defines the byte (or data packet) structure for the player entity.

class game.data.structures.player_structure.PlayerStructure

Bases: object

Byte structure for the player.

PLAYER_BROKEN_TILE_X_BYTE_SIZE = 1
PLAYER_BROKEN_TILE_Y_BYTE_SIZE = 1
PLAYER_NAME_BYTE_SIZE = 16
PLAYER_X_BYTE_SIZE = 2
PLAYER_Y_BYTE_SIZE = 2

data.structures.tile_structure

Module name: tile_structure

This module defines the byte (or data packet) structure for the map tile.

class game.data.structures.tile_structure.DynatileStructure

Bases: object

Byte structure for the dynamic tile. No pre-defined dynatile bit size as it can vary.

DYNATILE_ADJACENT_DUPLICATES_BYTE_SIZE = 2
DYNATILE_STATE_BYTE_SIZE = 1
class game.data.structures.tile_structure.TileStructure

Bases: object

Byte structure for the tile.

TILE_ADJACENT_DUPLICATES_BYTE_SIZE = 2
TILE_BYTE_SIZE = 3
TILE_DAMAGE_BIT_SIZE = 7
TILE_DAMAGE_BYTE_POS = 5
TILE_DAMAGE_DELAY_BIT_SIZE = 3
TILE_DAMAGE_DELAY_BYTE_POS = 2
TILE_RESISTANCE_BIT_SIZE = 6
TILE_RESISTANCE_BYTE_POS = 12
TILE_X_BIT_SIZE = 3
TILE_X_BYTE_POS = 21
TILE_Y_BIT_SIZE = 3
TILE_Y_BYTE_POS = 18

data.themes

Themes packages.

data.themes.theme

Module name: theme

This module allows for creating world themes.

class game.data.themes.theme.Theme(_id: int)

Bases: object

Class for creating a world theme object.

add_layer(layer_type: str, min_height: int, max_height: int, tile: Tile) Self

Add a theme layer, then return the theme itself.

clear_layers() Self

Clear all theme layers, then return the theme itself.

get_dict() dict[str, int | dict[str, str | int]]

Return the theme as a dictionary.

get_layers() list[list[dict[str, str | int]]] | list

Return the theme layers.

get_name() str

Return the theme name.

set_layers(layers: list[list[dict[str, str | int]]]) Self

Set the theme layers, then return the theme itself.

set_name(name: str) Self

Set the theme name, then return the theme itself.

data.themes.theme_layers

Module name: theme_layers

This module defines all the different theme layers

class game.data.themes.theme_layers.ThemeLayers

Bases: object

Class for defining the different types of theme layers.

LAYER_B = 'bottom'
LAYER_C = 'center'
LAYER_T = 'top'

data.themes.themes

Module name: themes

This module defines the different world themes.

class game.data.themes.themes.Themes

Bases: object

Class for creating a collection of world themes.

DEFAULT: Theme = <game.data.themes.theme.Theme object>
HELL: Theme = <game.data.themes.theme.Theme object>
HELL_ISLANDS: Theme = <game.data.themes.theme.Theme object>
ISLANDS: Theme = <game.data.themes.theme.Theme object>

data.tiles

Tiles package.

data.tiles.tile

Module name: tile

This module defines the map tile object and its properties.

class game.data.tiles.tile.Tile(_id: str = '', x: int = 0, y: int = 0)

Bases: object

Class for creating a map tile.

DEFAULT_ATLAS: str = '/home/docs/checkouts/readthedocs.org/user_builds/tile-game/checkouts/latest/game/assets/atlas.png'
compress() int

Return the compressed format of the tile’s attributes.

decompress(compressed_tile: int) Self

Extract the tile attributes from the compressed tile and set them accordingly.

get_damage() int

Return the damage amount of the tile.

get_damage_delay() float

Return the damage delay of the tile.

get_resistance() int

Return the resistance of the tile.

get_xy() tuple[int, int]

Return the texture coordinate of the tile.

set_damage(damage: int) Self

Set the damage amount of the tile, then return the tile itself.

set_damage_delay(damage_delay: float) Self

Set the damage delay of the tile, then return the tile itself.

set_resistance(resistance: int) Self

Set the resistance of the tile, then return the tile itself.

set_xy(x: int, y: int) Self

Set the texture coordinates of the tile, then return the tile itself.

data.tiles.tile_types

Module name: tile_types

This module defines the different types of map tiles.

class game.data.tiles.tile_types.TileTypes

Bases: object

Class for regrouping tiles into different categories.

BREAKABLE: tuple[Tiles] = (Tile((4, 0), 10, 0, 0.0), Tile((7, 0), 25, 0, 0.0))
LETHAL: tuple[Tiles] = (Tile((1, 1), 0, 3, 0.5),)
PLACEABLE: tuple[Tiles] = (Tile((0, 0), 0, 0, 0.0), Tile((1, 0), 0, 0, 0.0), Tile((2, 0), 0, 0, 0.0), Tile((3, 0), 0, 0, 0.0), Tile((4, 0), 10, 0, 0.0), Tile((5, 0), 0, 0, 0.0), Tile((0, 1), 0, 0, 0.0), Tile((1, 1), 0, 3, 0.5))

data.tiles.tiles

Module name: tiles

This module defines the different map tiles.

class game.data.tiles.tiles.Tiles

Bases: object

Class for creating a collection of tiles.

BREAK_TILES_ANIM: tuple[Tile] = (Tile((0, 7), 0, 0, 0.0), Tile((1, 7), 0, 0, 0.0), Tile((2, 7), 0, 0, 0.0), Tile((3, 7), 0, 0, 0.0), Tile((4, 7), 0, 0, 0.0), Tile((5, 7), 0, 0, 0.0), Tile((6, 7), 0, 0, 0.0), Tile((7, 7), 0, 0, 0.0))
COBBLESTONE: Tile = Tile((4, 0), 10, 0, 0.0)
COBBLESTONE_STAIRS: Tile = Tile((6, 0), 0, 0, 0.0)
DIRT: Tile = Tile((3, 0), 0, 0, 0.0)
FIRESTONE: Tile = Tile((7, 0), 25, 0, 0.0)
GRASS: Tile = Tile((1, 0), 0, 0, 0.0)
LAVA: Tile = Tile((1, 1), 0, 3, 0.5)
PLAINS: Tile = Tile((2, 0), 0, 0, 0.0)
SAND: Tile = Tile((5, 0), 0, 0, 0.0)
VOID: Tile = Tile((0, 0), 0, 0, 0.0)
WATER: Tile = Tile((0, 1), 0, 0, 0.0)