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.
    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
    Screen
  viewport: A pygame Rect whose size is equal to the screen size, indicating which portion of the world is currently on-screen.

Class Variable Summary
tuple TILE_SIZE = (300, 300)

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.

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.

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

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.

Class Variable Details

TILE_SIZE

Type:
tuple
Value:
(300, 300)