Table of Contents

Module: the_app rdpyg/app/the_app.py

TheApp is a class for making a game like application, implementing functionality common in many games. The idea is to make constructing games and demos quick, with minimal code.

TODO: a way to chose between display flip and update. without overriding the whole method.

There are a number of different methods with default implementations to save work. Most of these can be overridden if you need to specialise any parts.

= How the main loop works. =

TheApp class has a couple of different ways which it handles the main loop internally. It can use a while loop or the twisted reactor.

However by using the methods provided you should not have to modify this.

It can be instructional to have at a look at the source for different methods, so that overriding them can be easy.

This is the 2d pygame version of the class. There is an opengl version named rdpyg.app.the_app_gl.TheAppGL

= Commonly overridden methods =

  • Display Your drawing code. Update Updating your game logic, game play, and game ai. HandleEvents Code to handle user input, operating system interaction, and other events. Load * Code to load your game data. Like images, sounds etc.

= Order of operation =

The order in which the different methods get called is to update your game objects, handle user input, do your display changes.

Start() InitDislpay() Load()

Loop() Before loops starts looping: LoopInit() SetupTiming() Every tic or frame of loop: Update() HandleEvents() DoBeforeDisplay() Display() DoAfterFlip()

Imported modules   
import pygame
from pygame.locals import DOUBLEBUF, OPENGL, FULLSCREEN, QUIT, KEYDOWN, K_ESCAPE
import sys
import time
import traceback
Classes   

TheApp

An application class to handle lots of common things within games, and


Table of Contents

This document was automatically generated on Sat Jul 30 12:45:41 2005 by HappyDoc version 2.1