Phil's pyGame Utilities Documentation

Overview

Scripts
tileedit | leveledit | tganew | levelfancy

Reference
algo | ani | engine | fonts | high | html | layout | text | timer | vid

Tutorials
1 | 2 | 3 | 4 | 5

GUI Ref.
theme | style | widget | surface | const

Containers
container | app | table | document | area

Forms
form | group

Widgets
basic | button | input | keysym | slider | select | misc

Other
menus | dialog

Tutorials
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

vid

sections
Sprite
Sprite.setimage
Tile
Vid
Vid.resize
Vid.set
Vid.get
Vid.paint
Vid.update
Vid.tga_load_level
Vid.tga_save_level
Vid.tga_load_tiles
Vid.load_images
Vid.run_codes
Vid.string2groups
Vid.list2groups
Vid.groups2list
Vid.loop
Vid.screen_to_tile
Vid.tile_to_screen
Sprite and tile engine. tilevid, isovid, hexvid are all subclasses of this interface. Includes support for: * Foreground Tiles * Background Tiles * Sprites * Sprite-Sprite Collision handling * Sprite-Tile Collision handling * Scrolling * Loading from PGU tile and sprite formats (optional) * Set rate FPS (optional) This code was previously known as the King James Version (named after the Bible of the same name for historical reasons.)

Sprite

The object used for Sprites. Arguments: ishape -- an image, or an image, rectstyle. The rectstyle will describe the shape of the image, used for collision detection. pos -- initial (x,y) position of the Sprite. Attributes: rect -- the current position of the Sprite _rect -- the previous position of the Sprite groups -- the groups the Sprite is in agroups -- the groups the Sprite can hit in a collision hit -- the handler for hits -- hit(g,s,a) loop -- the loop handler, called once a frame

Sprite.setimage

Set the image of the Sprite. Arguments: ishape -- an image, or an image, rectstyle. The rectstyle will describe the shape of the image, used for collision detection.

Tile

Tile Object used by TileCollide. Arguments: image -- an image for the Tile. Attributes: agroups -- the groups the Tile can hit in a collision hit -- the handler for hits -- hit(g,t,a)

Vid

An engine for rendering Sprites and Tiles. Attributes: sprites -- a list of the Sprites to be displayed. You may append and remove Sprites from it. images -- a dict for images to be put in. size -- the width, height in Tiles of the layers. Do not modify. view -- a pygame.Rect of the viewed area. You may change .x, .y, etc to move the viewed area around. bounds -- a pygame.Rect (set to None by default) that sets the bounds of the viewable area. Useful for setting certain borders as not viewable. tlayer -- the foreground tiles layer clayer -- the code layer (optional) blayer -- the background tiles layer (optional) groups -- a hash of group names to group values (32 groups max, as a tile/sprites membership in a group is determined by the bits in an integer)

Vid.resize

Resize the layers. Arguments: size -- w,h in Tiles of the layers bg -- set to 1 if you wish to use both a foreground layer and a background layer

Vid.set

Set a tile in the foreground to a value. Use this method to set tiles in the foreground, as it will make sure the screen is updated with the change. Directly changing the tlayer will not guarantee updates unless you are using .paint() Arguments: pos -- (x,y) of tile v -- value

Vid.get

Get the tlayer at pos. Arguments: pos -- (x,y) of tile

Vid.paint

Paint the screen. Arguments: screen -- a pygame.Surface to paint to Returns the updated portion of the screen (all of it)

Vid.update

Update the screen. Arguments: screen -- a pygame.Rect to update Returns a list of updated rectangles.

Vid.tga_load_level

Load a TGA level. Arguments: g -- a Tilevid instance fname -- tga image to load bg -- set to 1 if you wish to load the background layer

Vid.tga_save_level

Save a TGA level. Arguments: fname -- tga image to save to

Vid.tga_load_tiles

Load a TGA tileset. Arguments: g -- a Tilevid instance fname -- tga image to load size -- (w,h) size of tiles in pixels tdata -- tile data, a dict of tile:(agroups, hit handler, config)

Vid.load_images

Load images. Arguments: idata -- a list of (name, fname, shape)

Vid.run_codes

Run codes. Arguments: cdata -- a dict of code:(handler function, value) rect -- a tile rect of the parts of the layer that should have their codes run

Vid.string2groups

Convert a string to groups.

Vid.list2groups

Convert a list to groups.

Vid.groups2list

Convert a groups to a list.

Vid.loop

Update and hit testing loop. Run this once per frame.

Vid.screen_to_tile

Convert a screen position to a tile position.

Vid.tile_to_screen

Convert a tile position to a screen position.

all content (c) 2006 Phil Hassey - Phil's pyGame Utilities