Phil's pyGame Utilities Documentation

Overview

Scripts
tileedit | leveledit | tganew | levelfancy

Reference
algo | ani | engine | fonts | high | html | layout | text | timer | vid

Tutorials
1 | 2 | 3 | 4 | 5

GUI Ref.
theme | style | widget | surface | const

Containers
container | app | table | document | area

Forms
form | group

Widgets
basic | button | input | keysym | slider | select | misc

Other
menus | dialog

Tutorials
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

engine

sections
State
State.init
State.paint
State.repaint
State.update
State.loop
State.event
Quit
Game
Game.run
Game.init
Game.tick
Game.event
a state engine.

State

Template Class -- for a state.
State(game,value...)
game

The state engine.

value

I usually pass in a custom value to a state

For all of the template methods, they should return None unless they return a new State to switch the engine to.

State.init

Template Method - Initialize the state, called once the first time a state is selected.
State.init()

State.paint

Template Method - Paint the screen. Called once after the state is selected.

State is responsible for calling pygame.display.flip() or whatever.

State.paint(screen)

State.repaint

Template Method - Request a repaint of this state.
State.repaint()

State.update

Template Method - Update the screen.

State is responsible for calling pygame.display.update(updates) or whatever.

State.update(screen)

State.loop

Template Method - Run a logic loop, called once per frame.
State.loop()

State.event

Template Method - Recieve an event.
State.event(e)

Quit

A state to quit the state engine.
Quit(game,value)

Game

Template Class - The state engine.

Game.run

Run the state engine, this is a infinite loop (until a quit occurs).
Game.run(state,screen=None)
game

a state engine

screen

the screen

Game.init

Template Method - called at the beginning of State.run() to initialize things.
Game.init()

Game.tick

Template Method - called once per frame, usually for timer purposes.
Game.tick()

Game.event

Template Method - called with each event, so the engine can capture special events.
Game.event(e): return captured

return a True value if the event is captured and does not need to be passed onto the current state


all content (c) 2006 Phil Hassey - Phil's pyGame Utilities