Skip to content

Pyxen Python Reference

All functions you can use are imported from the pyxen built in module.

Drawing

cls

pyxen.cls(r,g,b,a)

color

pyxen.color(r,g,b,a)

image

pyxen.image(name)

This function tells Pyxen which sprite sheet to use for next draw call.

The name is specified by the name parameter, as a string, without mentioning the file extension.

sprite

pyxen.sprite(x, y, tile_x, tile_y, tile_width, tile_height)

Draws a tile of a sprite. The sprite sheet used is specified by a previous call to pyxen.image.

The x,y parameters indicate where on the screen to draw the sprite. These are pixels in the virtual screen space, with top left corner being (0,0).

pivot

pyxen.pivot(x,y)

rotate

pyxen.rotate(angle)

scale

pyxen.scale(sx,sy)

Input

btn

pyxen.btn(num)

btnp

pyxen.btnp(num)

touch

pyxen.touch(finger)

Returns a tuple (down, x, y)

Maps

map

pyxen.mmap(name)

mdraw

pyxen.mdraw(x, y, first_col, first_row, num_cols, num_rows)

mget

pyxen.mget(col, row)

mset

pyxen.mset(col, row, value)

mhit

pyxen.mhit(x, y, width, height, flags)

mcollide

pyxen.mcollide(x, y, width, height, dx, dy, flags)

Perform a collision test between a moving rectangle and the map.

The coordinates of the rectangle, are given in pixels by x, y, width, height.

The movement of the rectangle is given by the vector dx, dy in fractional pixels.

Returns a tuple (x, y, collide_x, collide_y) with the new position indicated by (x,y). Two additional boolean (collide_x, collide_y) indicate respecively if a collision occured on any axis.

Sounds

sfxbank

pyxen.sfxbank(name)

Tell pyxenen what soundbank should be used for next calls to sfx.

Just pass the name of the soundbank, without file extension.

sfx

pyxen.sfx(name, volume, pan)

Play the sound named name located in the currently loaded soundbank (see sfxbank).

Volume and pan are optional parameters.

Volume is a float in range [0..1] and defaults to 1.0 for max volume, 0.0 being total silence.

Pan is used for playing stereo sounds. It defaults to 0.5 meaning play the sound at center. 0.0 is for completely left, and 1.0 for completely right sound output.

System

save

pyxen.save(key, value)

restore

pyxen.restore(key)

log

pyxen.log(message)

quit

pyxen.quit()