| |
- __builtin__.object
-
- CircleGeometry
- Ellipse
- LineGeometry
- PolyGeometry
- RectGeometry
- pygame.Rect(__builtin__.object)
-
- Diamond
class CircleGeometry(__builtin__.object) |
| |
Methods defined here:
- __init__(self, origin, radius)
- getorigin(self)
- getposition(self)
- GOTCHA: Something like "circle_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "circle_geom.position += (1,0)".
- getradius(self)
- setposition(self, val)
- setradius(self, val)
Static methods defined here:
- collided = circle_collided_other(self, other, rect_pre_tested=None)
- Return results of collision test between a circle and other geometry.
The *_collided_other() functions provide a convenient means to test
disparate geometries for collision. The logic considers containment to be
a collision. The tests do not check for the "self is other" condition.
self is a circle, it must have origin and radius attrs.
If other does not have a collided attr, then a circle-vs-rect result is
returned.
Otherwise...
other must have attr collided. collided must be a staticmethod
*_collided_other function or a custom function in that form. If collided is
not one of the *_collided_other functions, other's collided function will
be called passing arguments other and self in that order.
other's collided attr dictates the kind of self-vs-other collision test. The
builtin collision tests are:
1. If other.collided is circle_collided_other, other is assumed to be a
circle with origin and radius attrs.
2. If other.collided is rect_collided_other, other is assumed to be a
rect with a rect attr.
3. If other.collided is poly_collided_other, other is assumed to be a
poly with a points attr.
4. If other.collided is line_collided_other, other is assumed to be a
line with an end_points attr.
The fall-through action is to call other.collided(other, self), which is
assumed to be a custom staticmethod function.
Here is an example minimal class and usage:
class CircleGeom(object):
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
collided = staticmethod(circle_collided_other)
circle = CircleGeom(origin=(300,300), radius=25)
circle.collide(circle, other_poly)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- origin
- position
- GOTCHA: Something like "circle_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "circle_geom.position += (1,0)".
- radius
|
class Diamond(pygame.Rect) |
| |
- Method resolution order:
- Diamond
- pygame.Rect
- __builtin__.object
Methods defined here:
- __init__(self, *args)
- Diamond(left, top, width, height) : Rect
Diamond((left, top), (width, height)) : Rect
Diamond(object) : Rect
Construct it like a pygame.Rect. All the Rect attributes and methods
are available.
In addition, there are read-only attributes for:
* Individual corners: top_center, right_center, bottom_center, and
left_center.
* Individual edges: side_a, side_b, side_c, side_d.
* All corners as a tuple of coordinates: corners.
* All edges as a tuple of line segments: edges.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- bottom_center
- corners
- edges
- left_center
- right_center
- side_a
- side_b
- side_c
- side_d
- top_center
Methods inherited from pygame.Rect:
- __coerce__(...)
- x.__coerce__(y) <==> coerce(x, y)
- __copy__(...)
- __delitem__(...)
- x.__delitem__(y) <==> del x[y]
- __delslice__(...)
- x.__delslice__(i, j) <==> del x[i:j]
Use of negative indices is not supported.
- __eq__(...)
- x.__eq__(y) <==> x==y
- __ge__(...)
- x.__ge__(y) <==> x>=y
- __getitem__(...)
- x.__getitem__(y) <==> x[y]
- __getslice__(...)
- x.__getslice__(i, j) <==> x[i:j]
Use of negative indices is not supported.
- __gt__(...)
- x.__gt__(y) <==> x>y
- __le__(...)
- x.__le__(y) <==> x<=y
- __len__(...)
- x.__len__() <==> len(x)
- __lt__(...)
- x.__lt__(y) <==> x<y
- __ne__(...)
- x.__ne__(y) <==> x!=y
- __nonzero__(...)
- x.__nonzero__() <==> x != 0
- __reduce__(...)
- __repr__(...)
- x.__repr__() <==> repr(x)
- __setitem__(...)
- x.__setitem__(i, y) <==> x[i]=y
- __setslice__(...)
- x.__setslice__(i, j, y) <==> x[i:j]=y
Use of negative indices is not supported.
- __str__(...)
- x.__str__() <==> str(x)
- clamp(...)
- Rect.clamp(Rect): return Rect
moves the rectangle inside another
- clamp_ip(...)
- Rect.clamp_ip(Rect): return None
moves the rectangle inside another, in place
- clip(...)
- Rect.clip(Rect): return Rect
crops a rectangle inside another
- collidedict(...)
- Rect.collidedict(dict): return (key, value)
test if one rectangle in a dictionary intersects
- collidedictall(...)
- Rect.collidedictall(dict): return [(key, value), ...]
test if all rectangles in a dictionary intersect
- collidelist(...)
- Rect.collidelist(list): return index
test if one rectangle in a list intersects
- collidelistall(...)
- Rect.collidelistall(list): return indices
test if all rectangles in a list intersect
- collidepoint(...)
- Rect.collidepoint(x, y): return bool
Rect.collidepoint((x,y)): return bool
test if a point is inside a rectangle
- colliderect(...)
- Rect.colliderect(Rect): return bool
test if two rectangles overlap
- contains(...)
- Rect.contains(Rect): return bool
test if one rectangle is inside another
- copy(...)
- Rect.copy(): return Rect
copy the rectangle
- fit(...)
- Rect.fit(Rect): return Rect
resize and move a rectangle with aspect ratio
- inflate(...)
- Rect.inflate(x, y): return Rect
grow or shrink the rectangle size
- inflate_ip(...)
- Rect.inflate_ip(x, y): return None
grow or shrink the rectangle size, in place
- move(...)
- Rect.move(x, y): return Rect
moves the rectangle
- move_ip(...)
- Rect.move_ip(x, y): return None
moves the rectangle, in place
- normalize(...)
- Rect.normalize(): return None
correct negative sizes
- union(...)
- Rect.union(Rect): return Rect
joins two rectangles into one
- union_ip(...)
- Rect.union_ip(Rect): return None
joins two rectangles into one, in place
- unionall(...)
- Rect.unionall(Rect_sequence): return Rect
the union of many rectangles
- unionall_ip(...)
- Rect.unionall_ip(Rect_sequence): return None
the union of many rectangles, in place
Data descriptors inherited from pygame.Rect:
- __safe_for_unpickling__
- bottom
- bottomleft
- bottomright
- center
- centerx
- centery
- h
- height
- left
- midbottom
- midleft
- midright
- midtop
- right
- size
- top
- topleft
- topright
- w
- width
- x
- y
Data and other attributes inherited from pygame.Rect:
- __new__ = <built-in method __new__ of type object>
- T.__new__(S, ...) -> a new object with type S, a subtype of T
|
class Ellipse(__builtin__.object) |
| |
Methods defined here:
- __init__(self, origin, radius_x, radius_y)
- Construct an instance of Ellipse.
The origin argument is a sequence of two numbers representing the origin
(x,y).
The radius_x argument is a number representing the radius along x-axis.
The radius_y argument is a number representing the radius along y-axis.
- draw(self, surface, color, arcs=360)
- Draw an ellipse on a pygame surface in the specified color.
The surface argument is the target pygame surface.
The color argument is the pygame color to draw in.
The arcs argument is the number of points in the circumference to draw;
normally 360 or 720 will suffice. More than 720 will draw many duplicate
pixels.
- plot(self, arcs=360)
- Plot the circumference of an ellipse and return the points in a list.
The arcs argument is the number of points in the circumference to
generate; normally 360 or 720 will suffice. More than 720 will result in
many duplicate points.
The list that is returned is a sequence of (x,y) tuples suitable for
use with pygame.draw.lines().
- point(self, angle)
- Plot a point on the circumference of an ellipse at the specified angle.
The point is returned as an (x,y) tuple.
The angle argument is the angle in degrees from the origin. The angle 0
and 360 are oriented at the top of the screen, and increase clockwise.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- origin
- Set or get origin.
- radius_x
- Set or get radius_x.
- radius_y
- Set or get radius_y.
|
class LineGeometry(__builtin__.object) |
| |
Methods defined here:
- __init__(self, x1, y1, x2, y2, position=None)
- getend_points(self)
- getp1(self)
- getp2(self)
- getpoints(self)
- getposition(self)
- GOTCHA: Something like "line_geom.position.x += 1" will not do what
you expect. That operation does not update the line instance variable.
Instead use "line_geom.position += (1,0)".
- getx1(self)
- getx2(self)
- gety1(self)
- gety2(self)
- setp1(self, xorxy, y=None)
- setp2(self, xorxy, y=None)
- setpoints(self, endpoints)
- set end points of line
line.points = x1,y1,x2,y2
line.points = (x1,y1),(x2,y2)
- setposition(self, val)
- setx1(self, val)
- setx2(self, val)
- sety1(self, val)
- sety2(self, val)
Static methods defined here:
- collided = line_collided_other(self, other, rect_pre_tested=None)
- Return results of collision test between a line and other geometry.
self is a line, it must have an end_points attr.
See circle_collided_other description for other details.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- end_points
- p1
- p2
- points
- position
- GOTCHA: Something like "line_geom.position.x += 1" will not do what
you expect. That operation does not update the line instance variable.
Instead use "line_geom.position += (1,0)".
- x1
- x2
- y1
- y2
|
class PolyGeometry(__builtin__.object) |
| |
Methods defined here:
- __init__(self, points, position=None)
- getpoints(self)
- getposition(self)
- GOTCHA: Something like "poly_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "poly_geom.position += (1,0)".
- setposition(self, val)
Static methods defined here:
- collided = poly_collided_other(self, other, rect_pre_tested=None)
- Return results of collision test between a poly and other geometry.
self is a poly, it must have a points attr.
See circle_collided_other description for other details.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- points
- position
- GOTCHA: Something like "poly_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "poly_geom.position += (1,0)".
|
class RectGeometry(__builtin__.object) |
| |
Methods defined here:
- __init__(self, x, y, width, height, position=None)
- getpoints(self)
- getposition(self)
- GOTCHA: Something like "rect_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "rect_geom.position += (1,0)".
- setposition(self, val)
Static methods defined here:
- collided = rect_collided_other(self, other, rect_pre_tested=None)
- Return results of collision test between a rect and other geometry.
self is a rect, it must have a rect attr.
See circle_collided_other description for other details.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
- points
- position
- GOTCHA: Something like "rect_geom.position.x += 1" will not do what
you expect. That operation does not update the rect instance variable.
Instead use "rect_geom.position += (1,0)".
| |