pyaudiogame.App -- PyAudioGame API

API


pyaudiogame.App

pyaudiogame.App(title="Test app", fps=30)
The master/main class of the pyaudiogame engine. - title is the name of your application's window. - fps stands for frames per second and is how many times your game loop runs each second. The default is 30, but most graphical applications run at 60. Audio games do not use graphics, so don't really need the extra speed. Having the loop speed this low means that the app takes up much less memory.

pyaudiogame.App.__init__ The initialization function of the pyaudiogame.App class
pyaudiogame.App.logic The method/function where all the game logic goes.
pyaudiogame.App.set_defaults A method that is run in init. This is to make a nice easy way of setting default settings when sub-classing
pyaudiogame.App.run Creates the screen and starts the game loop
pyaudiogame.App.key_repeat Toggles and sets what holding down a key does
pyaudiogame.App.event_queue.schedule Place all events that need a timer in this function

Description

The pyaudiogame.App class provides the core functionality needed to run an application. It captures keyboard input and schedules and runs events.

logic

logic(actions) -> bool
The function you over-ride and fill with game logic.
Return a False when you wish the game loop to quit.
The actions is a dict of keyboard and mouse events as follows:
*['mousex'] The x coordinate of the mouse
*['mousey'] The y coordinate of the mouse
*['key'] The name of a key as a string. For example "space", "f", "return", "up"... To figure out what a key is, go to examples/keyboard_test.py
*['mouseClicked'] The state of the mouse click
*['mods'] a list of mod keys like ['ctrl', 'shift'] means that ctrl and shift are held down. ['shift'] means that just shift is held down

set_defaults

set_defaults(self) -> None
Should really only be sub-classed to change the class variables. it is run when the class is initialized.

run

run() -> None
Creates the screen and starts the game loop. Call this at the bottom of your main script to start the app.

key_repeat

key_repeat(self, on=True, delay=1000, delay_before_first_repeat=1)
Toggles on and off what happens when a key is held down.
call with on=False to turn it off and
just put delay=200
to turn it back on.

action_queue.schedule

schedule(function, delay=0, repeats=1, before_delay=False, *args, **kwargs)
Adds a function to the event queue to run delay seconds later.

default attributes/variables

These are settings that can be changed or accessed by typing App.variable_name.