physics

PP. physics

The namespace containing functions to manage physics
Source:

Namespaces

type

Methods

(static) add(s, obj, type)

Add an object to the physics engine. The object can be static (unmovable) or dynamic.
Source:
Parameters:
Name Type Description
s object The scene
obj object The object to add to the physics engine
type object PP.physics.type.STATIC or PP.physics.type.DYNAMIC

(static) add_collider(s, obj1, obj2)

Enable the collision between two objects.
Source:
Parameters:
Name Type Description
s object The scene
obj1 object The first object previously added to the physics engine
obj2 object The scond object previously added to the physics engine

(static) add_collider_f(s, obj1, obj2, func)

Enable the collision between two objects and execute a function when the collision occurs.
Source:
Parameters:
Name Type Description
s object The scene
obj1 object The first object previously added to the physics engine
obj2 object The scond object previously added to the physics engine
func function A function with the following parameters: func(s,a,b), where a and b are the collided objects

(static) add_overlap_f(s, obj1, obj2, func)

Execute a function when two objects overlaps.
Source:
Parameters:
Name Type Description
s object The scene
obj1 object The first object previously added to the physics engine
obj2 object The scond object previously added to the physics engine
func function A function with the following parameters: func(s,a,b), where a and b are the overlapped objects

(static) get_velocity_x(obj)

Get the current speed (in px/s) of the object over the horizontal axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physic enine

(static) get_velocity_y(obj)

Get the current speed (in px/s) of the object over the vertical axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics enine

(static) set_acceleration_x(obj, acc_x)

Set the acceleration (in px/s^2) of the object over the horizontal axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
acc_x float Acceleration in px/s^2

(static) set_acceleration_y(obj, acc_y)

Set the acceleration (in px/s^2) of the object over the vertical axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
acc_y float Acceleration in px/s^2

(static) set_allow_gravity(obj, gravity)

Enable/disable gravity value for this specific object
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
gravity boolean Gravity value (true or false)

(static) set_bounce_x(obj, bounce_x)

Set the bounce value over the horizontal axis (0: no bounce, 1: full bounce).
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
bounce_x float Horizontal axis bounce

(static) set_bounce_y(obj, bounce_x)

Set the bounce value over the vertical axis (0: no bounce, 1: full bounce).
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
bounce_x float Vertical axis bounce

(static) set_collide_world_bounds(obj, does_collide)

Enable or Disable the collision of an object with respect to the world bounds.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
does_collide boolean True or false if the object should collide.

(static) set_collision_circle(obj, radius, offset_x, offset_y)

Transform the rectangle of the collision boundaries in a circle
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
radius boolean Radius (in px)
offset_x boolean Offset of the circle on the x axis (in px)
offset_y boolean Offset of the circle on the y axis (in px)

(static) set_collision_offset(obj, offset_x, offset_y)

Change the offset x and y of the collision boundaries
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
offset_x boolean Offset of the circle on the x axis (in px)
offset_y boolean Offset of the circle on the y axis (in px)

(static) set_collision_rectangle(obj, width, height, offset_x, offset_y)

Change the rectangle size of the collision boundaries
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
width boolean Width (in px)
height boolean Height (in px)
offset_x boolean Offset of the rectangle on the x axis (in px)
offset_y boolean Offset of the rectangle on the y axis (in px)

(static) set_drag_x(obj, drag_x)

Set the drag on the horizontal axis
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
drag_x float Drag value

(static) set_drag_y(obj, drag_y)

Set the drag on the verical axis
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
drag_y float Drag value

(static) set_friction_x(obj, friction_x)

Set the horizontal friction of the material
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
friction_x float Friction value

(static) set_friction_y(obj, friction_y)

Set the vertical friction of the material
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
friction_y float Friction value

(static) set_immovable(obj, immovable)

Make a dynamic object as immovable. It has not effect on static objects.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
immovable boolean Should the object be immovable?

(static) set_rotation(obj, rot)

Set the rotation (in °/s) of the object.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physics engine
rot float The rotation speed

(static) set_velocity_x(obj, vel_x)

Set the speed (in px/s) of the object over the horizontal axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physic enine
vel_x float Speed in px/s

(static) set_velocity_y(obj, vel_y)

Set the speed (in px/s) of the object over the vertical axis.
Source:
Parameters:
Name Type Description
obj object The object previously added to the physic enine
vel_y float Speed in px/s