pyzzle :: Slide :: Slide :: Class Slide
[hide private]
[frames] | no frames]

Class Slide

source code

          object --+        
                   |        
pygame.sprite.Sprite --+    
                       |    
             Panel.Panel --+
                           |
                          Slide

The basic building blocks of myst games.

A typical slide represents a location the player can visit in the game world. Some slides may also represent items or switches that the player can interact with.

Every Slide has its own image file in the game world. When the player encounters the Slide, he is presented with this image. The player clicks on parts of the slide in order to perform certain actions. These parts of the slide are called Hotspots.

As a subclass of Panel, the Slide class resembles both the Sprite and Group classes of Pygame. As Sprites, they can blit an image to the screen, but as Groups, they can manage the behavior of other Sprites that are nested within them. Typically, Hotspots are the only Sprites nested within Slides, but it is possible to store other types of Sprites, such as Text, Movies, and even other Slides.

Instance Methods [hide private]
 
panHotspots(self, direction) source code
 
templateHotspots(self, link, direction) source code
 
_loadRefs(self) source code
 
_save(self) source code
 
__init__(self, id, file, stage=None, parent=None, ambiencefile=None, rectRel=None, layer=0, cursor='', visible=True, enabled=True)
Creates a slide.
source code
 
_loadImage(self, image) source code
 
_getImage(self)
The image displayed by the Slide.
source code
 
image(self)
The image displayed by the Slide.
source code
 
_getRect(self)
The portion of the screen occupied by the slide.
source code
 
rect(self)
The portion of the screen occupied by the slide.
source code
 
_setFile(self, file) source code
 
_getFile(self)
The name of the image file displayed by the Slide.
source code
 
_getAmbiencefile(self)
The name of the sound file that is played in a loop when the player reaches the slide.
source code
 
_setAmbiencefile(self, value) source code
 
draw(self, screen)
Draws the slide's image to screen, then draws any sprites within the Slide.
source code
 
enter(self, oldslide=None, delay=.1)
Called when the user enters the Slide.
source code
 
exit(self, newslide=None, delay=.1)
Called when the user exits the Slide.
source code

Inherited from pygame.sprite.Sprite: __repr__, add_internal, alive, groups, kill, remove_internal, update

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

    Inherited from Panel.Panel
 
__contains__(self, sprite) source code
 
__iter__(self) source code
 
_setRect(self, rect) source code
 
add(self, sprite)
Adds the sprite to the Panel.
source code
 
click(self, **param)
Called when the user clicks the Panel.
source code
 
empty(self)
Empties all nested sprites from the Panel.
source code
string
highlight(self)
Called when the cursor hovers over the Panel.
source code
 
remove(self, sprite)
Removes the sprite from the Panel.
source code
Static Methods [hide private]
 
_load(cells) source code
Class Variables [hide private]
  __metaclass__ = Table
  file = property(_getFile, _setFile)
  ambiencefile = property(_getAmbiencefile, _setAmbiencefile)
    Inherited from Panel.Panel
  cursorDefault = 'default.png'
Instance Variables [hide private]
  loaded
Whether the player has loaded the slide's image file in the current game session.
  links
All Hotspots that link to this slide when clicked.
  visited
Whether the player has previously visited the slide.
    Inherited from Panel.Panel
  enabled
Whether draw(), highlight(), and click() functions of the slide should be called by the parent panel.
  onEnter
The function that is called when the player enters the slide.
  onExit
The function that is called when the player exits the slide.
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, id, file, stage=None, parent=None, ambiencefile=None, rectRel=None, layer=0, cursor='', visible=True, enabled=True)
(Constructor)

source code 

Creates a slide. Parameters:

Parameters:
  • id - A unique identifier for the Slide. Used to refer to the Slide in scripts and the database
  • file - The name of the image file drawn by the slide.
  • stage (Stage) - An area of the game in which the slide occurs. Used to determine folder paths and default ambience/movement sounds.
  • parent (Panel) - The panel that the slide is nested within. The default is pyzzle.panel. Note: This will not add the slide to the panel. You still need to add it using Slide.enter() or one of the transition functions
  • ambiencefile - The name of the sound file that is played in a loop when the player reaches the slide.
  • rectRel (RelativeRect) - The rectangle occupied by the Slide. Currently, rect width and height do not resize the slide image.
  • layer (float) - The layer of the Slide. Larger numbers represent upper layers. When the player clicks on an area of the Slide where two Sprites overlap, the sprite with the topmost layer is the only one that's activated.
  • cursor - The name of the cursor file that is displayed when no hotspots are highlighted. The default is defined by Panel.cursorDefault. None displays no cursor.
Overrides: object.__init__

_getRect(self)

source code 

The portion of the screen occupied by the slide. rect coordinates are determined by rectRel. If a coordinate in rectRel is None, the coordinate is determined by the slide's image size.

Overrides: Panel.Panel._getRect

rect(self)

source code 

The portion of the screen occupied by the slide. rect coordinates are determined by rectRel. If a coordinate in rectRel is None, the coordinate is determined by the slide's image size.

Overrides: rect

_getFile(self)

source code 

The name of the image file displayed by the Slide. Resets self.loaded to False

_getAmbiencefile(self)

source code 

The name of the sound file that is played in a loop when the player reaches the slide. If none is specified, it returns the default for the slide's stage.

draw(self, screen)

source code 

Draws the slide's image to screen, then draws any sprites within the Slide.

Parameters:
  • screen - The surface to draw on.
Overrides: Panel.Panel.draw

enter(self, oldslide=None, delay=.1)

source code 

Called when the user enters the Slide.

Parameters:
  • oldslide (Panel) - The Panel that was previously presented to the user, to be replaced by self
  • delay - The time it should take for oldslide to transition to self
Overrides: Panel.Panel.enter

exit(self, newslide=None, delay=.1)

source code 

Called when the user exits the Slide.

Parameters:
  • newslide (Panel) - The Panel that was previously presented to the user, to be replaced by self
  • delay - The time it should take for oldslide to transition to self, in seconds
Overrides: Panel.Panel.exit