Home | Trees | Index | Help |
---|
|
A physics engine for platform games.
The physics engine manages a collection of bodies. These bodies are moved automatically, based on their velocities, by callingupdate
at regular intervals; and can also
be moved explicitly (e.g., with move
).
Method Summary | |
---|---|
__init__(self)
| |
add(self,
body)
| |
Return a list of all bodies managed by the physics engine | |
Return a list of all bodies intersecting the given point. | |
Return a list of all bodies intersecting the given rect. | |
If it is possible to move the given body by the specified distance without causing a collision at the destination, then do so. | |
jump_to(self,
body,
x,
y,
check_collisions)
| |
Move the given body (and any supported bodies) by the specified distance. | |
move_to(self,
body,
x,
y,
report_collisions)
| |
remove(self,
body)
| |
Attempt to change the given body's bounding box to bbox . | |
Update the positions of all bodies in the world. | |
Check if moving the given body by (dx,dy) would cause a collision with any other body; and if so, then raise a _Collision exception describing it. | |
Check if moving the given body by (dx,dy) would cause a collision with any other body. | |
Move the given body by the specified distance. | |
Given that moving body by (dx,dy) causes a collision with the bounding box obs_bbox , figure out which side it collided with it
on. | |
Try to move the given body up to be adjacent with the body specified by the given collision. | |
_move_with_supporteds(self,
body,
dx,
dy,
report_collisions)
| |
Move the given body (but not supported bodies) by the specified distance. | |
Given that body is a body supported by a support, and
that the support is moving by the given distance, return
True if this body should be moved before the support (to
prevent the support from colliding with it). | |
_update_mobilebody(self,
body,
interval,
pos)
|
Instance Variable Summary | |
---|---|
_body_grid : A grid containing all bodies managed by the physics engine. | |
_pseudobody_grid : A grid containing 'pseudobodies.' These don't interact with other
bodies in any way, but act as place markers for some objects (e.g.,
background objects like trees). |
Class Variable Summary | |
---|---|
bool |
debug = False
|
int |
_GRID_SIZE = 60 |
Method Details |
---|
__init__(self)
|
add(self, body) |
bodies(self, include_nonsolids=True)
|
bodies_intersecting_point(self, x, y, include_nonsolids=True)
|
bodies_intersecting_rect(self, rect, include_nonsolids=True)
|
jump(self, body, dx, dy, check_collisions=True)If it is possible to move the given body by the specified distance without causing a collision at the destination, then do so. Otherwise, just return False. Do not move supported objects.
|
jump_to(self, body, x, y, check_collisions=True) |
move(self, body, dx, dy, report_collisions=True)Move the given body (and any supported bodies) by the specified distance. If the movement results in a collision (by this body -- not supported ones), then generate collision messages for both colliding bodies, and return False. Otherwise, return True.
|
move_to(self, body, x, y, report_collisions=True) |
remove(self, body) |
set_bbox(self, body, bbox, check_collisions=True)Attempt to change the given body's bounding box tobbox . If that would cause a collision, then just return
false; do not perform the move or generate any collision messages.
|
update(self, interval, pos)Update the positions of all bodies in the world. Bodies that are close to the given pos (within 1000 pixels or so) will be updated at a much higher frequency than bodies that are farther away. |
_check_collide(self, body, dx, dy)Check if moving the given body by (dx,dy) would cause a collision with any other body; and if so, then raise a_Collision exception describing it.
|
_check_collide_path(self, body, dx, dy)Check if moving the given body by (dx,dy) would cause a collision with any other body. If dx>body.width or dy>body.height, then also check for collisions at intermediate locations on the path. If moving by (dx,dy) would cause a collision, then raise a_Collision exception describing it.
|
_do_move(self, body, dx, dy)Move the given body by the specified distance. Do not check for collisions. Do not move supported objects. |
_get_collision_side(self, body, obs_bbox, dx, dy)Given that moving body by (dx,dy) causes a collision with the bounding boxobs_bbox , figure out which side it collided
with it on.
|
_move_to_collision(self, body, collision, dx, dy, report_collisions)Try to move the given body up to be adjacent with the body specified by the given collision. If this movement causes a new collision, then the new collision takes precedence. When possible, the body will 'slide' along the obstacle (rather than just sticking to it). I.e., if it collides in the x direction, then it will still attempt to move the specified in the y direction; and vice versa.
|
_move_with_supporteds(self, body, dx, dy, report_collisions) |
_move_without_supporteds(self, body, dx, dy, report_collisions)Move the given body (but not supported bodies) by the specified distance. If the movement results in a collision (by this body -- not supported ones), then generate collision messages for both colliding bodies, and return False. Otherwise, return True.
|
_moves_before(self, body, dx, dy)Given thatbody is a body supported by a support, and
that the support is moving by the given distance, return
True if this body should be moved before the support (to
prevent the support from colliding with it).
|
_update_mobilebody(self, body, interval, pos) |
Instance Variable Details |
---|
_body_gridA grid containing all bodies managed by the physics engine. |
_pseudobody_gridA grid containing 'pseudobodies.' These don't interact with other bodies in any way, but act as place markers for some objects (e.g., background objects like trees). |
Class Variable Details |
---|
debug
|
_GRID_SIZE
|
Home | Trees | Index | Help |
---|
Generated by Epydoc 2.1 on Thu Sep 22 22:52:44 2005 | http://epydoc.sf.net |