pyaudiogame.ui -- PyAudioGame API

API


pyaudiogame.ui

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.

description

pyaudiogame.ui provides classes to perform some of the more common tasks in game development such as creating menus, diologues and maps.

class pyaudiogame.Menu

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={})



Menu.run Runs the menu and will speak the options.

run

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'].

class pyaudiogame.Typer

Creates a box which handles typing.
Typer(title="", valid_characters=['letters_simple', 'capitals', 'numbers', 'punctuation_simple'], multiline=False, length=0, current_string="")

Typer.run Runs the typer and searches for valid characters to put into the box

run

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.

class pyaudiogame.Grid

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

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

*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.