Physics

class miniworldmaker.physics.physics.PhysicsProperty[source]

The PhysicsProperty class describes all properties necessary to physically simulate an object using the pymunk engine.

The properties are defined in the method setup_physics(). You can override this method if you want your class to have different physical properties.

For an object to be physically simulated, the method start_physics() must first be called.

friction

Friction is the force resisting the relative motion of solid surfaces, fluid layers, and material elements sliding against each other. Friction has a value > 0

Type

int

elasticity

continuum mechanics of bodies that deform reversibly under stress

Type

int

mass

The mass of an object. Default: 1

stable

If True, the Object has no moment and can’t be rotated by an impulse

can_move

Defines if the object can move

gravity

Defines if the object affected by gravity

shape_type

line, circle or rect

collision_types

alias of builtins.list

simulation_postprocess_token()[source]

Reloads physics model from pygame data Returns:

simulation_preprocess_token()[source]

Updates the physics model in every frame

Returns:

start_physics()[source]

Starts the physcis-simulation for this object. If you want to use Physics-Sumulation with your object, you have to use this method.

WARNING: This method should be called AFTER all changes of attributes but BEFORE you add an impulse to the object

Examples

>>> # These attributes are changed BEFORE start_physics()
>>> self.physics.size = 0.7, 0.7
>>> self.physics.shape_type = "circle"
>>> self.physics.stable = False
>>> # The physics simulation is started
>>> self.start_physics()
>>> # The impulse is applied to the object AFTER starting the physics simulation
>>> self.physics.velocity_x = 1500
>>> self.physics.velocity_y = - self.board.arrow.direction * 50