Items

Collection of different items. The items can for example be assigned to a Teemap or a Layer. You can generate new items and just put them in the appropriate place in a map, they will be recognized automatically when you save your map.

copyright:2010-2012 by the TML Team, see AUTHORS for more details.
license:GNU GPL, see LICENSE for more details.
class tml.items.Envelope(name=None, version=None, channels=None, envpoints=None, synced=True)

Represents an envelope.

The envelopes for a map should be in the list Teemap.envelopes.

class tml.items.Envpoint(time=None, curvetype=None, values=None)

Represents an envpoint.

Envpoints are part of envelopes and should be in the envpoints list of an envelope.

class tml.items.Group(name=None, offset_x=0, offset_y=0, parallax_x=100, parallax_y=100, use_clipping=0, clip_x=0, clip_y=0, clip_w=0, clip_h=0, layers=None)

Represents a group.

The groups of a map should be assigned to Teemap.groups

append(layer)

Adds a layer to the group.

Parameters:layer – Layer to append.
Raises :TypeError
class tml.items.Image(name, width=0, height=0, external=False, data=None, path='')

Represents an image.

The images for a map should be in the list Teemap.images.

save(dest)

Saves the image to the given path.

Parameters:dest – Path to the image
class tml.items.Info(author=None, map_version=None, credits=None, license=None, settings=None)

Represents a map info object.

Should be assigned to Teemap.mapinfo.

class tml.items.Layer(detail)

Represents the layer data every layer has.

A layer must always be part of a Group, assign it to the Group.layers list.

Warning

This is just the parent class for QuadLayer and TileLayer, do not assign it to a teemap!

class tml.items.Quad(pos_env=-1, pos_env_offset=0, color_env=-1, color_env_offset=0, points=None, colors=None, texcoords=None)

Represents a quad of a quadlayer.

class tml.items.QuadLayer(name='Quads', detail=False, image_id=-1, quads=None)

Represents a quadlayer.

A layer must always be part of a Group, assign it to the Group.layers list.

Parameters:
  • name – Name of the layer
  • image_id – ID of the related image
  • quads – Initial QuadManager, used internally
class tml.items.QuadManager(quads=None, data=None)

Handles quads while sparing memory.

Keeps track of quads as simple strings, but returns a Quad class on demand.

Note

Because QuadManager generates Quad classes on-the-fly, you need to assign new quad explicity. This will not work like you would expect:

>>> layer.quads[10].rotate('l')

Instead, you need to re-assign the quad:

>>> quad = layer.quads[10]
>>> quad.rotate('l')
>>> layer.quads[10] = quad

We are searching for a better solution, in the meanwhile, use this workaround

Parameters:
  • quads – List of quads to put in.
  • data – Raw quad data, used internally.
class tml.items.SpeedupTile(data)

Represents a speedup tile of a tilelayer. Only for race modification.

class tml.items.TeleTile(data)

Represents a tele tile of a tilelayer. Only for race modification.

class tml.items.Tile(index=0, flags=0, skip=0, reserved=0)

Represents a tile of a tilelayer.

coords

Coordinates of the tile in the mapres.

Returns:(x, y)
flags

Gives the flags of the tile.

The flags contain the rotation, hflip and vflip information.

Returns:{‘rotation’: int, ‘vflip’: int, ‘hflip’: int}
hflip()

Flip the tile in horizontal direction

rotate(value)

Rotate the tile.

Parameters:value (str) – Rotationdirection, can be (l)eft or (r)ight
Raises :ValueError
vflip()

Flip the tile in vertical direction

class tml.items.TileLayer(width=50, height=50, name='Tiles', detail=False, game=0, color=(255, 255, 255, 255), color_env=-1, color_env_offset=0, image_id=-1, tiles=None, tele_tiles=None, speedup_tiles=None)

Represents a tilelayer.

A layer must always be part of a Group, assign it to the Group.layers list.

Parameters:
  • game – 1 if it should be the gamelayer. Default: 0
  • color – Tupel with four values for r, g, b, a Default: (255, 255, 255, 255)
  • tiles – Initial TileManager, used internally
  • tele_tiles – Only for race modification
  • speedup_tiles – Only for race modification
draw(x, y, tilelayer)

Draws the the passed tilelayer onto itself.

If the given tilelayer is too big, it will be cut and the rest discarded.

get_tile(x, y)

Get a tile by its coordinates.

select(x, y, w=1, h=1)

Select an area of the tilelayer.

Creates a new TileLayer of the section you are selecting. If you are selecting over the borders, it will just cut your selection to fit to the layer.

Returns:TileLayer
set_tile(x, y, tile)

Set a tile by coordinates.

class tml.items.TileManager(size=0, tiles=None, data=None, _type=0)

Handles tiles while sparing memory.

Keeps track of tiles as simple strings, but returns a Tile class on demand.

Note

Because TileManager generates Tile classes on-the-fly, you need to assign new tiles explicity. This will not work like you would expect:

>>> layer.tiles[10].rotate('l')

Instead, you need to re-assign the tile:

>>> tile = layer.tiles[10]
>>> tile.rotate('l')
>>> layer.tiles[10] = tile

We are searching for a better solution, in the meanwhile, use this workaround

Parameters:
  • size – Fill up the manager with n empty tiles.
  • tiles – List of tiles to put in.
  • data – Raw tile data, used internally.
  • _type – Used for a race modification, you probably don’t need it

Previous topic

Tutorial

Next topic

Exceptions

This Page