Package pajammin :: Package display :: Module engine :: Class DisplayEngine
[show private | hide private]
[frames | no frames]

Type DisplayEngine

object --+
         |
        DisplayEngine


A graphics engine for platform games.
Method Summary
  __init__(self, width, height, delay_init, background)
Create a new platform graphics engine, containing no sprites.
  add(self, widget)
Add a widget to the graphics engine.
  init(self, background_file)
Initialize the graphics engine, and set its background.
  remove(self, widget)
Remove a widget from the graphics engine.
  screenpos(self, worldpos)
Return the screen position corresponding to the world position worldpos, given the current location of the viewport.
  update(self, duration)
Update all on-screen sprites' animations, draw them onto the screen at their current position, and update the display.
  worldpos(self, screenpos)
Return the world position corresponding to the screen position screenpos, given the current location of the viewport.
  _clear(self)
Erase all sprites from the screen (but do not update the display).
  _draw(self, duration)
Update all on-screen sprites' animations, draw them onto the screen at their current position, and update the display.
  _get_background(self)
  _set_background(self, background_file)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
Return hash(x)...
  __new__(T, S, ...)
Return a new object with type S, a subtype of T...
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
Return repr(x)...
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
Return str(x)...

Property Summary
  background: The name of the image that should be displayed in the background.
  height: The height of the screen, in pixels.
  size: The size of the screen, in pixels.
  width: The width of the screen, in pixels.

Instance Variable Summary
    Widgets
  _screen_widgets: A list of the widgets that should be drawn relative to the screen, sorted by layer.
  _world_widgets: A ProximityGrid of the widgets that should be drawn relative to world coordinates.
    Screen
  _screen: The display screen.
  _screen_size: The size of the screen.
  viewport: A pygame Rect whose size is equal to the screen size, indicating which portion of the world is currently on-screen.
  _dirty_rects: A list of the screen-relative rectangles that were modified by the last call to _draw().
    Background
  _background_file: The filename of the file containing the current background image.
  _background: The current background image.

Class Variable Summary
tuple TILE_SIZE = (300, 300)
str _background_style = 'center'

Method Details

__init__(self, width=640, height=480, delay_init=False, background=None)
(Constructor)

Create a new platform graphics engine, containing no sprites. If delay_init is True, then initialization of the actual display is not done; in this case, the init method must be called to initialize the graphical display before the graphics engine is used.
Parameters:
width, height - The size of the display.
background - The filename of the file containing the initial background image.
Overrides:
__builtin__.object.__init__

add(self, widget)

Add a widget to the graphics engine. This will cause the widget to be displayed whenever its location is on-screen.

init(self, background_file=None)

Initialize the graphics engine, and set its background.

remove(self, widget)

Remove a widget from the graphics engine. This will cause the graphics engine to stop displaying the widget. (It will be erased on the next screen-refresh, such as a call to update).

screenpos(self, worldpos)

Returns:
The screen position corresponding to the world position worldpos, given the current location of the viewport.

update(self, duration)

Update all on-screen sprites' animations, draw them onto the screen at their current position, and update the display.

Then erase all sprites, but do not update the display. This ensures that they will be properly erased from their old locations on the next call to draw, before they are drawn in their new locations.
Parameters:
duration - The time since the last call to draw(), used to decide how much to advance the animations.

worldpos(self, screenpos)

Returns:
The world position corresponding to the screen position screenpos, given the current location of the viewport.

_clear(self)

Erase all sprites from the screen (but do not update the display). This should be called after draw, but before any sprites have been moved.

_draw(self, duration)

Update all on-screen sprites' animations, draw them onto the screen at their current position, and update the display.
Parameters:
duration - The time since the last call to draw(), used to decide how much to advance the animations.

_get_background(self)

_set_background(self, background_file)


Property Details

background

The name of the image that should be displayed in the background. If background is set to None, then a default (solid color) background is used. If the image loaded from the specified file is not the same size as the screen, then it will be tiled.
Get Method:
_get_background(self)
Set Method:
_set_background(self, background_file)

height

The height of the screen, in pixels.
Get Method:
unknown-7606832(...)

size

The size of the screen, in pixels.
Get Method:
unknown-7606896(...)

width

The width of the screen, in pixels.
Get Method:
unknown-7606576(...)

Instance Variable Details

_screen_widgets

A list of the widgets that should be drawn relative to the screen, sorted by layer.

_world_widgets

A ProximityGrid of the widgets that should be drawn relative to world coordinates.

_screen

The display screen.

_screen_size

The size of the screen.

viewport

A pygame Rect whose size is equal to the screen size, indicating which portion of the world is currently on-screen. The position of viewport may be modified, but you should not change its size.

_dirty_rects

A list of the screen-relative rectangles that were modified by the last call to _draw(). This list is used by _clear() to decide where to redraw the background; and by the next call to _draw() to make sure it updates the screen in all the areas that were redrawn by _clear().

_background_file

The filename of the file containing the current background image.

_background

The current background image.

Class Variable Details

TILE_SIZE

Type:
tuple
Value:
(300, 300)                                                             

_background_style

Type:
str
Value:
'center'