Package pygsear :: Module Game :: Class Game
[show private | hide private]
[frames | no frames]

Class Game

GameLooper --+
             |
            Game

Known Subclasses:
TwistedGame

The central game object.

Classes which subclass this take part in the pygsear game framework and automatically get a splash screen, and the configuration interface.
Method Summary
  __init__(self, window)
  configure(self, pygame_event, **kwargs)
Bring up the configuration screen
  freeMouse(self, free)
Stop capturing all input
  gameOver(self)
Show a Game Over message.
  grabMouse(self, grab)
Capture all mouse and keyboard input
  hideMouse(self, hide)
Hide the mouse cursor
  initialize(self)
Further initialization
  mainloop(self, frames)
The main game loop.
  playAgain(self)
Ask if player wants to play again.
  resize_reset(self)
Fix up the game after the screen has been resized
  restart(self)
  set_background(self, filename, img, tilename, tile, color)
Set the background.
  set_title(self, title)
  showMouse(self, show)
Show the mouse cursor
  splash_screen(self)
Show the splash screen
  splash_screen_poof(self)
Erase the splash screen
  step(self)
Take one trip through the mainloop
  unpause(self)
  update(self, areas)
update the display
  waitFor(self, key, timeout)
Pause the game, waiting for a keystroke.
    Inherited from GameLooper
  addEventGroup(self, event)
return a Event.EventGroup
  addGroup(self, sprites, layer)
return a SpriteGroup
  addLayer(self, size)
return a Drawable.Layer and keep track.
  beep(self)
  checkCollisions(self)
Defaults to no collision checks.
  checkEvents(self)
  loop(self)
  pause(self)

Class Variable Summary
str splash_filename = 'pygsear_logo.png'

Method Details

configure(self, pygame_event, **kwargs)

Bring up the configuration screen

freeMouse(self, free=1)

Stop capturing all input
Parameters:
free - 1 yes release or 0 no grab

gameOver(self)

Show a Game Over message.

grabMouse(self, grab=1)

Capture all mouse and keyboard input

Also keeps mouse locked inside of window.
Parameters:
grab - 1 yes grab or 0 no release

hideMouse(self, hide=1)

Hide the mouse cursor
Parameters:
hide - 1 yes hide or 0 no show

initialize(self)

Further initialization

Most games will create their main objects here.

mainloop(self, frames=0)

The main game loop.
Parameters:
frames - number of times to loop Defaults to 0, which means loop until the game is over.

playAgain(self)

Ask if player wants to play again.

resize_reset(self)

Fix up the game after the screen has been resized

set_background(self, filename=None, img=None, tilename=None, tile=None, color=(0, 0, 0))

Set the background.

See Also: Screen.Layer

showMouse(self, show=1)

Show the mouse cursor
Parameters:
show - 1 yes show or 0 no hide

splash_screen(self)

Show the splash screen

Called as soon as window is created

Game subclasses which do not want a splash screen can override this with a function that just does pass

splash_screen_poof(self)

Erase the splash screen

Called at the end of __init__

Game subclasses which do not want a splash screen should also override this with a function that just does pass

step(self)

Take one trip through the mainloop

update(self, areas=None)

update the display
Parameters:
areas - rect or list of rects to update

waitFor(self, key=13, timeout=None)

Pause the game, waiting for a keystroke.

Still allows the game to be ended by clicking the window close button.

Class Variable Details

splash_filename

Type:
str
Value:
'pygsear_logo.png'                                                     

Generated by Epydoc 2.0 on Sat Dec 9 14:11:20 2006 http://epydoc.sf.net