Проверить Matter.js
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
790B

  1. // module aliases
  2. var Engine = Matter.Engine,
  3. Render = Matter.Render,
  4. Runner = Matter.Runner,
  5. Bodies = Matter.Bodies,
  6. Composite = Matter.Composite;
  7. // create an engine
  8. var engine = Engine.create({
  9. enableSleeping: true,
  10. });
  11. // create a renderer
  12. var render = Render.create({
  13. element: document.body,
  14. engine: engine
  15. });
  16. // create two boxes and a ground
  17. var ground = Bodies.rectangle(400, 500, 700, 50, { isStatic: true });
  18. var boxA = Bodies.rectangle(401, 240, 40, 20);
  19. var boxB = Bodies.rectangle(415, 470, 40, 20, { isStatic: true });
  20. // add all of the bodies to the world
  21. Composite.add(engine.world, [boxA, boxB, ground]);
  22. // run the renderer
  23. Render.run(render);
  24. // create runner
  25. var runner = Runner.create();
  26. // run the engine
  27. Runner.run(runner, engine);