Welcome to the Elements Manual
This page will guide you along the first steps with Elements, you are heartly invited to
visit our IRC channel #elements on irc.freenode.net. No matter which timezone, there are
always friendly people around which are happy to
help out and discuss issues and ideas :-)
Let's begin with an overview of the important
concepts.
[[comment manual]]
Drawing Methods
Elements can draw with different methods:
- cairo
- pygame
- opengl_pyglet
- (more coming soon :)
Be default, it is set to pygame, and can be changed on initializing Elements:
If the drawing method needs a surface, it can be passed to the renderer with:
[[comment manual.drawing_methods]]
Internal Coordinate Systems
Elements Box2D OpenGL Cairo Pygame
+y +y +y +-------> +x +-------> +x
^ ^ ^ | |
| | | | |
| | | | |
| | | | |
+-------> +x +-------> +x +-------> +x V +y V +y
[[comment manual.internal_coordinate_systems]]
Input of Coordinates
Elements will translate all input parameters to it's internal coordinate system (also called world coordinate system).
The input coordinate system (screen coordinate system) is by default set to pygames,
which means that adding an object at (0,0)
will let it appear in the upper left corner. You can change the origin of your system with:
For example if your game uses the same (screen) coordinate system as Elements, you need to set:
elements.set_inputAxisOrigin(left=True, top=False)
[[comment manual.input_coordinates]]
Input Unit System (pixels or meters)
Elements supports both, pixels and meters as input for lengths and positions. By default, the input units
are recognized as pixels, and will be translated into meters by the given ppm value (see
elements.__init__).
If you want to change the default input system (so you can supply the elements api
with parametersin meters rather than pixels), you can do so with
Supported Unit Systems are:
INPUT_METERS
INPUT_PIXELS
[[comment manual.input_unit_system]]
Line Width (Filled or border)
You can set the border width of the objects to any pixel number,
or to 0 if you want to fill the shapes.
world.line_width = 4
[[comment manual.line_width]]
Callbacks
With callbacks, user can start own functions on specified events with elements.callbacks.add. Currently supported callback types are:
CALLBACK_CONTACT_ADD
CALLBACK_CONTACT_PERSIST
CALLBACK_CONTACT_REMOVE
[[comment manual.callbacks]]
List of Densities of Various Materials
Init: p = m / V ([p] = kg / m³)
Air 0.001225
Liquid ammonia 0.682
Oil 0.8
Water 1.0
Glycerine 1.26
Concrete 2.4
Aluminium 2.7
Iron 7.87
Copper 8.92
Lead 11.35
Mercury 13.6
Gold 19.3
Platinum 21.4
Osmium 22
[[comment manual.densities]]