Package pype :: Module sprite :: Class DisplayList
[frames] | no frames]

Class DisplayList

source code

object --+
         |
        DisplayList

Sprite-list manager.

DisplayList collects and manages a set of Sprites so you can worry about other things.

Each sprite is assigned a priority or stacking order. Low numbers on top, high numbers on the bottom. When you ask the display list to update, the list is sorted and blitted bottom to top (the order of two sprites with the same priority is undefined).

The other useful thing is that the UserDisplay class (see userdpy.py) has a display() method that takes a display list and draws simplified versions of each sprite on the user display so the user can see (approximately) what the monkeys is seeing.

NB Sprites are only drawn when they are on (see on() and off() methods for Sprites).

Instance Methods
 
__init__(self, fb, comedi=True)
Instantiation method.
source code
 
__del__(self)
Delete method.
source code
 
add(self, s, timer=None, on=None, onev=None, off=None, offev=None)
Add sprite to display list.
source code
 
delete(self, s=None)
Delete single or multiple sprites from display list.
source code
 
clear(self)
Delete all sprites from the display list.
source code
 
delete_all(self)
Delete all sprites from display list.
source code
 
after(self, time=None, action=None, args=None)
Set up an action to be called in the future.
source code
 
update(self, flip=None, preclear=1)
Draw sprites on framebuffer
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, fb, comedi=True)
(Constructor)

source code 
Instantiation method.
Parameters:
  • fb - framebuffer associated with this list. This is sort of redundant, since each sprite knows which framebuffer it lives on too. It's currently only used for clearing and flipping the framebuffer after updates.
Overrides: object.__init__

__del__(self)
(Destructor)

source code 

Delete method.

Called when the display list is deleted. Goes through and tries to delete all the member sprites. The idea is that if you delete the display list at the each of each trial, this function will clean up all your sprites automatically.

add(self, s, timer=None, on=None, onev=None, off=None, offev=None)

source code 

Add sprite to display list.

Each time self.update is called, the timer will be checked and used to decide whether to turn this sprite on or off.

Parameters:
  • s - (Sprite/list of Sprites) sprites are added in depth order
  • timer - (Timer) Timer object to use as clock
  • on - (ms) time to turn sprite on
  • onev - (str) encode to store for on event
  • off - (ms) time to turn sprite off
  • offev - (str) encode to store for off event
Returns:
nothing

delete(self, s=None)

source code 

Delete single or multiple sprites from display list.

NB Same as clear() and delete_all() methods if called with no arguments.

Parameters:
  • s - (sprite) sprite (or list of sprites) to delete, or None for delete all sprites.
Returns:
nothing

clear(self)

source code 

Delete all sprites from the display list.

Same as delete_all().

delete_all(self)

source code 

Delete all sprites from display list.

Same as clear().

after(self, time=None, action=None, args=None)

source code 

Set up an action to be called in the future.

After 'time' ms, the action function will be called with three arguments: requested elapsed time, actual elapsed time and the user-specfied args.

Parameters:
  • time - (ms) ms on the timer
  • action - (fn) function to call
  • args - (anything) passed as third arg to 'action' function
Returns:
nothing

update(self, flip=None, preclear=1)

source code 

Draw sprites on framebuffer

  1. Clear screen to background color (if specified)
  2. Draw all sprites (that are 'on') from bottom to top
  3. Optionally do a page flip.
Parameters:
  • flip - (boolean) flip after?
  • preclear - (boolean) clear first?
Returns:
list of encodes (from timer-triggered sprites)