gummworld2.basicmap (version $Id: basicmap.py 407 2013-08-12 15:11:30Z stabbingfinger@gmail.com $)
index
c:\cygwin\home\bw\devel\python\svn\gummworld2_devel\gamelib\gummworld2\basicmap.py

basicmap.py - Basic Map module for Gummworld2.
 
Defines the BasicMap, which serves layers and sprite objects.
 
BasicMap combines view (pygame) and model (world coordinates). It contains a
rect attribute defining its dimensions, and observes pygame coordinate space.
 
The layers attribute is a spatialhash containing sprites. This can be
accessed directly, or via the class methods. See also the toolkit module for
convenience utilities.
 
The caller must manage maps and their corresponding worlds by swapping the
State.map and State.world package globals, for example:
    
    # Create the initial map and world, and save it.
    State.map = BasicMap(width, height, tile_width, tile_height)
    State.world = model.World(State.map.rect)
    levels = []
    levels.append((State.map,State.world))
    ...
    # Create a new one, save it.
    State.map = BasicMap(new_width, new_height, new_tile_width, new_tile_height)
    State.world = model.World(State.map.rect)
    levels.append((State.map,State.world))
    ...
    # Restore a map and world.
    State.map,State.world = levels[0]
    
Alternatively State.save() and State.restore() can be used to facilitate this.

 
Modules
       
gummworld2.data
pygame
gummworld2.spatialhash

 
Classes
       
__builtin__.object
BasicLayer
BasicMap

 
class BasicLayer(__builtin__.object)
     Methods defined here:
__init__(self, parent_map, layer_index)
__iter__(self)
add(self, tile)
blit_layer(self, src_layer)
collapse(self, collapse=(1, 1))
get_objects_in_rect(self, rect)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class BasicMap(__builtin__.object)
     Methods defined here:
__init__(self, width, height, tile_width, tile_height)
Construct a BasicMap object.
collapse(self, collapse=(1, 1), which_layers=None)
Collapse which_layers by joining num_tiles into one tile. The
original layers are replaced by new layers.
 
The collapse argument is the number of tiles on the X and Y axes to
join.
 
The collapse_layers argument is a sequence of indices indicating to
which TiledMap.layers the collapse algorithm should be applied. See the
tiledmap.collapse_map.
get_layer(self, layer_index)
get_layers(self, which_layers=None)
get_objects_in_rect(self, rect, layeri=0)
merge_layers(self, which_layers=None)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
blit_layer(dest_layer, src_layer)
collapse_layer(old_layer, new_layer, num_tiles=(2, 2))
Collapse a single layer by joining num_tiles into one tile. A new layer
is returned.
 
The old_layer argument is the layer to process.
 
The new_layer argument is the layer to build.
 
The num_tiles argument is a tuple representing the number of tiles in the X
and Y axes to join.
 
If a map area is sparse (fewer tiles than num_tiles[0] * num_tiles[1]) the
tiles will be kept as they are.
 
If tiles with different characteristics are joined, the results can be
unexpected. These characteristics include some flags, depth, colorkey. This
can be avoided by pre-processing the map to convert all images so they have
compatible characteristics.

 
Data
        __author__ = 'Gummbum, (c) 2011-2013'
__version__ = '$Id: basicmap.py 407 2013-08-12 15:11:30Z stabbingfinger@gmail.com $'
text_color = (255, 255, 0, 255)

 
Author
        Gummbum, (c) 2011-2013