games Module functions


games Module functions

The games module defines functions for working with images, sound, and music, which I list in Table A.9.

Table A.9: games FUNCTIONS

Function

Description

load_image(file_name [, transparent])

Returns an image object loaded from the file named in the string file_name and sets transparency if transparent is equal to a value that can be treated as True. The default value of transparent is a value that can be treated as True.

scale_image(image, x_scale [, y_scale])

Returns a new image object scaled in the x direction by a factor of x_scale and in the y direction by a factor of y_scale. If no value is passed to y_scale, then the image is scaled by a factor of x_scale in both directions. The original image image is unchanged.

load_sound(file_name)

Returns a sound object from a WAV file named in the string file_name.

load_music(file_name)

Loads music from the file named in the string file_name.

play_music([loop])

Plays the current music loop number of times in addition to its initial playing. A value of -1 means loop forever. The default value of loop is 0.

fade_out_music(millisec)

Fades out the current music in millisec milliseconds.

stop_music()

Stops the current music.

The sound object returned by load_sound() has several methods available to it, which are listed in Table A.10.

Table A.10: SOUND OBJECT METHODS

Method

Description

play([loop])

Plays the sound loop number of times in addition to its initial playing. A value of -1 means loop forever. The default value of loop is 0.

fadeout(millisec)

Fades out the sound in millisec milliseconds.

stop()

Stops the sound on all channels.




Python Programming for the Absolute Beginner
Python Programming for the Absolute Beginner, 3rd Edition
ISBN: 1435455002
EAN: 2147483647
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net