Package tdl :: Module event :: Class App |
[frames] | no frames]

# Class App

source code

    object --+
             |
            App

Application framework.

- ev_*: Events are passed to methods based on their Event.type attribute. If an event type is 'KEYDOWN' the ev_KEYDOWN method will be called with the event instance as a parameter.
- key_*: When a key is pressed another method will be called based on the KeyEvent.key attribute. For example the 'ENTER' key will call key_ENTER with the associated KeyDown event as its parameter.
- update: This method is called every loop. It is passed a single parameter detailing the time in seconds since the last update (often known as deltaTime.)

  You may want to call drawing routines in this method followed by tdl.flush.

Instance Methods
ev_QUIT(self, event) Unless overridden this method raises a SystemExit exception closing the program. | source code
ev_KEYDOWN(self, event) Override this method to handle a KeyDown event. | source code
ev_KEYUP(self, event) Override this method to handle a KeyUp event. | source code
ev_MOUSEDOWN(self, event) Override this method to handle a MouseDown event. | source code
ev_MOUSEUP(self, event) Override this method to handle a MouseUp event. | source code
ev_MOUSEMOTION(self, event) Override this method to handle a MouseMotion event. | source code
update(self, deltaTime) Override this method to handle per frame logic and drawing. | source code
suspend(self) When called the App will begin to return control to where App.run was called. | source code
run(self) Delegate control over to this App instance. | source code
runOnce(self) Pump events to this App instance and then return. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### update(self, deltaTime) | source code
Override this method to handle per frame logic and drawing. Parameters: `deltaTime` (float) - This parameter tells the amount of time passed since the last call measured in seconds as a floating point number. You can use this variable to make your program frame rate independent. Use this parameter to adjust the speed of motion, timers, and other game logic.

### suspend(self) | source code
When called the App will begin to return control to where App.run was called. Some further events are processed and the App.update method will be called one last time before exiting (unless suspended during a call to App.update.)

### run(self) | source code
Delegate control over to this App instance. This function will process all events and send them to the special methods ev_* and key_*. A call to App.suspend will return the control flow back to where this function is called. And then the App can be run again. But a single App instance can not be run multiple times simultaneously.

### runOnce(self) | source code
Pump events to this App instance and then return. This works in the way described in App.run except it immediately returns after the first update call. Having multiple App instances and selectively calling runOnce on them is a decent way to create a state machine.