The class which handles all interaction with the box2d engine.
As a convenience, most of the top-level variables in elements have been placed inside a module named 'elements.locals'. This is meant to be used with 'from elements.locals import *', in addition to 'import elements'.
[[comment elements]]
elements.__init__
constructor of the elements class elements.__init__(screen_size, gravity=(0.0, -9.0), ppm=100.0)): return Elements()
Parameters: screen_size .. (w, h) is the screen size in pixels, gravity .. (x, y) in m/s^2 [float] and ppm .. pixels per meter [int]
This function is called on a world = Elements()
[[comment elements.__init__]]
elements.draw
draw the scene with a specified method elements.draw(surface): return None
If a drawing method is specified, this function passes the objects to the module in pixels.
Parameters: surface ... can be used for whatever the method needs for drawing
[[comment elements.draw]]
elements.reset_color
new objects will be added with random colors elements.reset_color(): return None
All objects from now on will be drawn in random colors
[[comment elements.reset_color]]
elements.set_color
new objects will be added with specified color elements.set_color(clr): return None
clr can either be a hex color '#123123' or a rgb color ((0), (0), (0))
[[comment elements.set_color]]
elements.set_drawingMethod
set a drawing method (pygame, ...) elements.set_drawingMethod(m): return True / False
Returns True if method is found, False if not.
The parameter m can be for now only 'pygame'.
[[comment elements.set_drawingMethod]]
elements.set_inputAxisOrigin
configure the input coordinate system elements.set_inputAxisOrigin(left=True, top=False): return None
Change the origin of the input coordinate system axis
Parameters:
left ... True or False -- x = 0 is at the left?
top .... True or False -- y = 0 is at the top?
[[comment elements.set_inputAxisOrigin]]
elements.set_inputUnit
configure input unit system (pixels or meters) elements.set_inputUnit(input): return None
The parameter input can be INPUT_PIXELS (1) or INPUT_METERS (0)
[[comment elements.set_inputUnit]]
elements.set_screenSize
set current screen size elements.set_screenSize(m): return None
The parameter size is ((width), (height)) in pixels
[[comment elements.set_screenSize]]
elements.update
Update the physics, if not paused (self.run_physics) elements.update(fps=50.0, iterations=10): return None
The optional parameter fps specifies the frames per seconds the engine is supposoed to run,
iteration is the number of substeps per step (for smoother simulations)