@@ -145,6 +145,7 @@ def collide(ax0, ay0, ax1, ay1, bx0, by0, bx1=None, by1=None):
145
145
146
146
147
147
class Audio :
148
+ """Play sounds."""
148
149
last_audio = None
149
150
150
151
def __init__ (self , speaker_pin , mute_pin = None ):
@@ -156,14 +157,21 @@ def __init__(self, speaker_pin, mute_pin=None):
156
157
self .audio = audioio .AudioOut (speaker_pin )
157
158
158
159
def play (self , audio_file , loop = False ):
160
+ """
161
+ Start playing an open file ``audio_file``. If ``loop`` is ``True``,
162
+ repeat until stopped. This function doesn't block, the sound is
163
+ played in the background.
164
+ """
159
165
self .stop ()
160
166
wave = audioio .WaveFile (audio_file )
161
167
self .audio .play (wave , loop = loop )
162
168
163
169
def stop (self ):
170
+ """Stop playing whatever sound is playing."""
164
171
self .audio .stop ()
165
172
166
173
def mute (self , value = True ):
174
+ """Enable or disable all sounds."""
167
175
if self .mute_pin :
168
176
self .mute_pin .value = not value
169
177
@@ -289,7 +297,8 @@ def move(self, x, y, z=None):
289
297
class WallGrid (Grid ):
290
298
"""
291
299
A special grid, shifted from its parents by half a tile, useful for making
292
- nice-looking corners of walls and similar structures."""
300
+ nice-looking corners of walls and similar structures.
301
+ """
293
302
294
303
def __init__ (self , grid , walls , bank , palette = None ):
295
304
super ().__init__ (bank , grid .width + 1 , grid .height + 1 , palette )
@@ -341,7 +350,14 @@ def move(self, x, y, z=None):
341
350
self .layer .move (int (x ), int (y ))
342
351
343
352
def set_frame (self , frame = None , rotation = None ):
344
- """Set the current graphic and rotation of the sprite."""
353
+ """
354
+ Set the current graphic and rotation of the sprite.
355
+
356
+ The possible values for rotation are: 0 - none, 1 - 90° clockwise,
357
+ 2 - 180°, 3 - 90° counter-clockwise, 4 - mirrored, 5 - 90° clockwise
358
+ and mirrored, 6 - 180° and mirrored, 7 - 90° counter-clockwise and
359
+ mirrored.
360
+ """
345
361
346
362
if frame is not None :
347
363
self .frame = frame
0 commit comments