Skip to content

Commit 66bdcc7

Browse files
committed
Update docs
1 parent 054d226 commit 66bdcc7

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

README.rst

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ st7735r
2828

2929
ugame
3030
=======
31-
.. automodule:: ugame
32-
:members:
31+
.. module:: ugame
32+
33+
.. data:: display
34+
35+
An initialized display, that can be used for creating Stage objects.
36+
37+
.. data:: buttons
38+
39+
An instance of ``GamePad`` or other similar class, that has a
40+
``get_pressed`` method for retrieving a bit mask of pressed buttons. That
41+
value can be then checked with & operator against the constants: ``K_UP``,
42+
``K_DOWN``, ``K_LEFT``, ``K_RIGHT``, ``K_X``, ``K_O`` and on some platforms
43+
also: ``K_START`` and ``K_SELECT``.
44+
45+
.. data:: audio
3346

47+
And instance of the ``Audio`` or other similar class, that has ``play``,
48+
``stop`` and ``mute`` methods.

stage.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def collide(ax0, ay0, ax1, ay1, bx0, by0, bx1=None, by1=None):
145145

146146

147147
class Audio:
148+
"""Play sounds."""
148149
last_audio = None
149150

150151
def __init__(self, speaker_pin, mute_pin=None):
@@ -156,14 +157,21 @@ def __init__(self, speaker_pin, mute_pin=None):
156157
self.audio = audioio.AudioOut(speaker_pin)
157158

158159
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+
"""
159165
self.stop()
160166
wave = audioio.WaveFile(audio_file)
161167
self.audio.play(wave, loop=loop)
162168

163169
def stop(self):
170+
"""Stop playing whatever sound is playing."""
164171
self.audio.stop()
165172

166173
def mute(self, value=True):
174+
"""Enable or disable all sounds."""
167175
if self.mute_pin:
168176
self.mute_pin.value = not value
169177

@@ -289,7 +297,8 @@ def move(self, x, y, z=None):
289297
class WallGrid(Grid):
290298
"""
291299
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+
"""
293302

294303
def __init__(self, grid, walls, bank, palette=None):
295304
super().__init__(bank, grid.width + 1, grid.height + 1, palette)
@@ -341,7 +350,14 @@ def move(self, x, y, z=None):
341350
self.layer.move(int(x), int(y))
342351

343352
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+
"""
345361

346362
if frame is not None:
347363
self.frame = frame

0 commit comments

Comments
 (0)