Elements: Difference between revisions

From OLPC
Jump to navigation Jump to search
m (+box2d demo)
(info update +box2d)
Line 6: Line 6:
The ''Elements'' project is all about '''free and easy 2D physics for python''' -- with main attention on:
The ''Elements'' project is all about '''free and easy 2D physics for python''' -- with main attention on:
# An '''easy-to-use''', fast 2D physics API
# An '''easy-to-use''', fast 2D physics API
#* for the [http://wiki.slembcke.net/main/published/Chipmunk Chipmunk] 2d physics engine (with [http://code.google.com/p/pymunk/ pymunk] ctypes bindings)
#* for the (faster) [http://www.box2d.org/ box2d] physics engine (work in progress)
#* and soon for the [http://www.box2d.org/ box2d] physics engine (work in progress)
#* and [[Elements/Chipmunk|previously]] also for the [http://wiki.slembcke.net/main/published/Chipmunk Chipmunk] 2d physics engine (with [http://code.google.com/p/pymunk/ pymunk] ctypes bindings)
#* See: [[Physic Engines/Speed Tests]]
# Examples and documentation on how to use the API
# Examples and documentation on how to use the API
# Providing the examples as bundles, as they are already interesting and fun
# Providing the examples as bundles, as they are already interesting and fun
Line 19: Line 20:
== More Informations ==
== More Informations ==
* IRC: #elements on irc.freenode.net
* IRC: #elements on irc.freenode.net
* Project started by [[User:Crazy-chris|Chris Hager]], March 2008. Source-Code is GPL licensed - so do with it what you want! Even eat it :)
* Source-Code is GPL licensed - so do with it what you want! Even eat it :)
* The ''Elements'' project derived from [[pymunx]], which started as examples for pymunk and is growing up to a real physics api for python
* The 2D physics is handled by the chipmunk physics engine (written in C by ...)
* Communication to the chipmunk library is done via the pymunk ctypes bindings (by Victor Blomqvist.)
* A lively and open development and support team is having fun improving and helping out :)
* A lively and open development and support team is having fun improving and helping out :)
* The Box2D compatible version of '''Elements''' will come these days. In the meantime the Chipmunk engine is almost fully supported by the [[Elements/Chipmunk|previous version]] of Elements.
* Features: ''fast, easy to use, segments, polygons, circles, colissions, variable gravity, density, mass, friction, elasticity, inertia, impulses, screenshots, screencasts, cross-platform, entertaining, fascinating, ...''

* Limitations which will be implemented soon: Joints, Grouped Elements and Non-convex Polygons. Screencast encoding currently works only in linux with mencoder installed.

== Team ==
* [[User:Crazy-chris|Chris Hager]]
* Joshua Minor
* [[User:Ixo|Ixo]]




Line 34: Line 37:


[[Image:Screenshot3.png|400px]] [[Image:Screenshot4.png|400px]]
[[Image:Screenshot3.png|400px]] [[Image:Screenshot4.png|400px]]


== Videos ==


== Downloads ==
* [http://www.linuxuser.at/elements/elements.zip Elements.zip] (338 kb): Elements API, demos, pymunk, compiled chipmunk libs (and, for the curious, the Chipmunk sources)
* [http://www.linuxuser.at/elements/elements.xo Elements.xo] (195 kb) ... ''Demo selection bundle for the XO laptop''
* ''<tt>svn checkout http://pymunk.googlecode.com/svn/trunk/ pymunk-read-only</tt>'' ... ''Pymunk with demos and docs''
* [http://files.slembcke.net/chipmunk/release/ChipmunkLatest.tgz ChipmunkLatest.tgz] ... ''The source of the Chipmunk physics engine (written in C)''


== Documentations ==
* [[Elements/Documentation|Elements API Documentation]]
* [http://www.linuxuser.at/pymunx/pymunk_api Pymunk API]
* [http://files.slembcke.net/chipmunk/chipmunk-docs.html Chipmunk Docs]


== Examples ==
http://www.linuxuser.at/Elements/demos
''Examples''
* [http://www.linuxuser.at/Elements/demos/demo1_ballsnsquares.py demo1_ballsnsquares.py] ''(most simple :)''
* [http://www.linuxuser.at/Elements/demos/demo2_drawwalls.py demo2_drawwalls.py] ''(create new walls)''
* [http://www.linuxuser.at/Elements/demos/demo3_addmany.py demo3_addmany.py] ''(add more objects at once)''
* [http://www.linuxuser.at/Elements/demos/demo4_drawpoly.py demo4_drawpoly.py] ''(draw a polygon)''
* [http://www.linuxuser.at/Elements/demos/demo5_draw.py demo5_draw.py] ''(tryout for segments (buggy))''
* [http://www.linuxuser.at/Elements/demos/demo6_throw_and_settings.py demo6_throw_and_settings.py] ''(++) (adjust elasticity, density, size and throw in objects)''
* [http://www.linuxuser.at/Elements/demos/demo7_elasticbox.py demo7_elasticbox.py] ''(++) (elastic walls all around. very funny :)''
* [http://www.linuxuser.at/Elements/demos/demo8_gravityfun.py demo8_gravityfun.py] ''(+++) (change the gravity vector (or set to (0,0) by right mouse click)''





Revision as of 19:47, 18 March 2008

Elements banner1.jpg


About

The Elements project is all about free and easy 2D physics for python -- with main attention on:

  1. An easy-to-use, fast 2D physics API
  2. Examples and documentation on how to use the API
  3. Providing the examples as bundles, as they are already interesting and fun
  4. Speed optimization (also with an eye on the XO laptop :)
  5. Development of ideas for education and playful-learning


Elements.zip (338 kb) | Elements.xo (195 kb) | box2d xo demo | Documentation | Browse Source


More Informations

  • IRC: #elements on irc.freenode.net
  • Source-Code is GPL licensed - so do with it what you want! Even eat it :)
  • A lively and open development and support team is having fun improving and helping out :)
  • The Box2D compatible version of Elements will come these days. In the meantime the Chipmunk engine is almost fully supported by the previous version of Elements.


Team


Screenshots

(from Elements/Screenshots)

Screenshot1.png Screenshot2.png

Screenshot3.png Screenshot4.png


Pygame Example

The typical usage in pygame can look like this:

      import pygame
      from pygame.locals import *
      from pygame.color import *   

      from elements import *
       
      pygame.init()
      screen = pygame.display.set_mode((800, 800))
      clock = pygame.time.Clock()

      world = elements()
      world.add_wall((100, 200), (300, 200))
         
      # Main Game Loop:
      while running:
         # Event Handling
         # Maybe calling world.add_ball(event.pos) or world.add_square(event.pos)
         # ...

         screen.fill((255,255,255))

         # Update & Draw World
         world.update()
         world.draw(screen)

         # Flip Display
         pygame.display.flip()
          
         # Try to stay at 50 FPS
         clock.tick(50)