Package pajammin :: Module physics
[show private | hide private]
[frames | no frames]

Module pajammin.physics

The physics engine, which implements the basic physics for the bodies of each entity. In particular, the physics engine handles:

Bodies

Each body has a set of basic properties defining its position and movement:

Solid Flags

Additionally, each body defines a set of flags which determine when it will collide with other bodies.

First, the is_solid flag determines whether the body can collide with other bodies at all. If it false, then the body will never collide with anything.

For solid bodies (i.e., bodies where is_solid=True), the solid_sides flags indicates which sides of the body are solid. If a given side of a body is solid, then any solid body that moving into or through the body from that side will collide with it. When two solid objects pass into or through each other, only one of the objects needs to be solid on the relevant side to cause a collision. Some examples should help clarify:

Support

A body can be 'supported' by another body that it is adjacent to. For example, when the player stands on a platform, it is supported by that platform. If body B is supported by body S, then: If the supported body moves to a position where it is no longer adjacent to the supporting body, then it automatically becomes unsupported.
Classes
Body An object in the physics engine.
PhysicsEngine A physics engine for platform games.

Exceptions
_Collision An exception that is raised when two objects collide.

Variable Summary
int COLLISION = 1                                                                     
int LOSE_SUPPORT = 8                                                                     
int MOVEMENT = 4                                                                     

Variable Details

COLLISION

Type:
int
Value:
1                                                                     

LOSE_SUPPORT

Type:
int
Value:
8                                                                     

MOVEMENT

Type:
int
Value:
4