pyaudiogame.ui
PyAudioGame's prebuilt interfaces.
pyaudiogame.ui.Menu | Creates a menu object with options one can scroll through using the keyboard. |
pyaudiogame.ui.Typer | Creates a Typer object which handles text input. |
pyaudiogame.ui.Grid | Makes a grid and has functions for map creation. |
pyaudiogame.ui provides classes to perform some of the more common tasks in game development such as creating menus, diologues and maps.
Creates a class which can handle keyboard input to navigate a menu
Menu(options=["yes", "no"], default_position=0, keys={"back": "up", "forward": "down", "exit": ["escape", "backspace"], "except": "return"}, shortkeys=None, title="Test Menu", loops=True, persistent=0, sounds={})
default_position
['back']
the key that is used to go up or left through a menu, default is "up" ['forward']
the key that is used to go down or right through a menu. Default is "down" ['exit']
The key that is used to get out of the menu. This returns "exit" from the run function. Default keys are "escape" and "backspace" ['except']
The key that will choose an option and returns it from the run function. Default key is "return" default_position
default_position
default_position
. But if they hit except on an option, if they go back, their last selection will be the one selected. ['change']
for when the back or forward keys are pressed ['exit']
for when the exit key is pressed ['except']
for when the except key is pressed
Menu.run | Runs the menu and will speak the options. |
run(actions) -> choice
Will run the menu. It will return the option the user selects. Otherwise it will return None. If the user hits the exit key, "exit" will be returned.
Pass it the actions dict from the logic function.
otherwise, the only key it pulls from the dict is ['key']
.
Creates a box which handles typing.
Typer(title="", valid_characters=['letters_simple', 'capitals', 'numbers', 'punctuation_simple'], multiline=False, length=0, current_string="")
valid_characters
Typer.character_sets
dict. Default sets are: 'letters_simple'
no capital letters 'punctuation_simple'
.,-_'\"
punctuation_medium'
\/[]
=-` multiline
allows for users to hit "return" to get a newline character.current_string
is default text that is typed in the edit box before the user enters anything. Typer.run | Runs the typer and searches for valid characters to put into the box |
run(actions) -> text string
This returns a text string when the user hits except.
pass in a dict with the "key" item in it. Prefferably the one from App.logic.
Creates a grid, primarily for map creation.
Grid(width=50, height=50)
Note that what happens is that a grid object is created and it has info about stuff you put in that grid, like walls and whatnot.
Grid.check | Checks if there is an object in that location |
Grid.add_wall | Adds a wall object to the grid |
check(x, y) -> bool
Run this to check if the point at (x, y) is in an object. If yes, this function returns True.
add_wall
add_wall(min_x=1, max_x=10, min_y=5, max_y=5) -> WallObject
min_x, max_x
min_y, max_y
*note*
a Wall consists of the length of the x Wall and the length of the y Wall. so if you draw a line from the min_x
to the max_x,
that is how wide the wall will be. If you do the same to the min_y
and max_y
lines, you will get the height of the wall.
So a wall that is 1,10 and 5,5, will be 10 squares long and 1 square high. A pretty clasic wall.