Package pygsear :: Module Drawable :: Class Shape
[show private | hide private]
[frames | no frames]

Class Shape

object --+        
         |        
    Sprite --+    
             |    
      Drawable --+
                 |
                Shape

Known Subclasses:
Circle, Rectangle

Simple geometric shapes.
Method Summary
  __init__(self, w)
Initialize Drawable sprite.
  paint(self)
Change the color of the shape.
  set_color(self, color, r, g, b)
Set the color for drawing.
    Inherited from Drawable
bool can_see(self, target, blocking_rects_list)
Performs a los (line of sight) check from the center of the source to the center of the target.
  center(self, x, y, dx, dy)
Align the Drawable in its layer
  clear(self, surface)
Erase sprite to background
bool collide(self, other)
return True if this sprite and other sprite overlap.
Drawable or False collidelist(self, lothers)
return True if this sprite and any in list of others collide.
List collidelistall(self, lothers)
return True if this sprite and any in list of others collide.
  direction(self, point)
return the direction from the sprite to a point
  distance(self, point)
return the distance from the sprite to a point
  draw(self, surface)
Blit image to layer
  get_position(self)
return a copy of the sprite's position
  get_size(self)
return size of sprite's rect.
  move(self)
set position to next position on path
  nudge(self, dx, dy)
Move sprite.
  onscreen(self, slack, **kw)
return True if image is on the screen or layer.
  pause(self)
stop moving along Path
  runPath(self, frames)
call move() continuously
  set_crect(self, crect)
set the collision pygame.Rect used for collision checking.
  set_path(self, path)
set which path to follow
  set_position(self, location, *args)
Move sprite to location.
  set_positionRandom(self, slack)
Move sprite to a random location on screen
  set_size(self, size)
Set size of sprite's rect.
  solid(self, other, move_both)
move sprite so that it does not overlap with other sprite
  stretch(self, dx, dy, size, keepAspectRatio)
Change the size of sprite's image, and rect.
  uclear(self, surface)
clear sprite and update display
  udraw(self, surface)
Draw image and update display.
  unpause(self)
start moving along Path
  _set_position(self, location)
Move sprite to location.
    Inherited from Sprite
  __repr__(self)
  add(self, *groups)
add(group or list of of groups, ...) add a sprite to container
  add_internal(self, group)
  alive(self)
alive() -> bool check to see if the sprite is in any groups
  groups(self)
groups() -> list of groups list used sprite containers
  kill(self)
kill() remove this sprite from all groups
  remove(self, *groups)
remove(group or list of groups, ...) remove a sprite from container
  remove_internal(self, group)
  update(self, *args)
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)
    Inherited from type
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T

Method Details

__init__(self, w=None)
(Constructor)

Initialize Drawable sprite.
Parameters:
w - Layer on which sprite lives.
Overrides:
pygsear.Drawable.Drawable.__init__ (inherited documentation)

paint(self)

Change the color of the shape.

set_color(self, color=None, r=None, g=None, b=None)

Set the color for drawing.

The caller can choose one of a few ways to set the color:
  • an RGB tuple can be passed in as the color parameter (or as the first argument)
  • one or more of r, g, and b parameters can (also) be passed as that portion of the color tuple.

    If these are given in addition to the color parameter, these will override the elements in the color tuple. ie. set_color((10, 10, 10), r=50) will set the color to (50, 10, 10)

    If these are given with NO color tuple passed, the resulting color will start with the current color, with the new elements being set from the passed parameters ie, if the color is (100, 100, 100) before the call, calling set_color(g=50, b=50) will set the color to (100, 50, 50)
  • if no parameters are passed at all, the color is set to WHITE.
Parameters:
color - an RGB tuple, or the word 'random' which will choose a color at random from (not quite) all possible.
r - The red value of the color (0 - 255)
g - The green value of the color (0 - 255)
b - The blue value of the color (0 - 255)

Generated by Epydoc 2.0 on Sat Dec 9 14:11:19 2006 http://epydoc.sf.net