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.
>>> class Player(miniworldmaker.Token): >>> def on_setup(self): >>> pass # setup Object >>> def setup_physics(self): >>> self.physics.size = (0.8, 0.8) >>> self.physics.shape_type = "circle" Creates a Physics Player. By creating the method setup_physics, the object will be run by physics engine.
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
The mass of an object. Default: 1
If True, the Object has no moment and can’t be rotated by an impulse
Defines if the object can move
Defines if the object affected by gravity
line, circle or rect
Adds an impulse in token-direction
power – The power-value of the impulse.
Removes an object from physics-space
Reloads physics model from pygame data Returns:
Updates the physics model in every frame
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 If you implement a setup_physics()-Method in an token, you don’t have to call this method.
>>> # 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