How to use the matter-js.Engine.create function in matter-js

To help you get started, we’ve selected a few matter-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plinko-team / plinko / src / server / serverEngine.js View on Github external
constructor({ io }) {
    this.users = new UserCollection();
    this.activeUsers = new UserCollection();
    this.io = io;
    this.engine = Engine.create();
    this.frame = 0;
    this.inputBuffer = new InputBuffer();
    this.waitingQueue = new WaitingQueue();
    this.gameIsRunning = false;
    this.playerIds = {0: null, 1: null, 2: null, 3: null};

    console.log('New ServerEngine created!')
  }
github vibertthio / runn / src / renderer / renderer.js View on Github external
initMatter() {
    this.engine = Engine.create();
  }
github redbadger / website-honestly / site / pages / our-work / case-study / camden-market / shapes / index.js View on Github external
engageMusic(container: HTMLDivElement) {
    const containerRectangle = container.getBoundingClientRect();
    const height = containerRectangle.bottom - containerRectangle.top;
    const engine = Engine.create({
      render: {
        element: container,
        options: {
          background: 'transparent',
          wireframes: false,
          width: window.innerWidth,
          height,
        },
      },
    });

    const nrand = () => {
      let x1;
      let x2;
      let rad;
      do {
github GraphQLCollege / graphql-college / components / Burger.js View on Github external
componentDidMount() {
    this.matterEngine = Engine.create();

    this.matterRender = Render.create({
      canvas: this.element,
      engine: this.matterEngine,
      options: {
        wireframes: false,
        width: 300,
        height: 300,
        background: "transparent"
      }
    });

    this.showBurger();
  }
  componentDidUpdate() {
github FormidableLabs / react-game-kit / src / native / components / world.js View on Github external
constructor(props) {
    super(props);

    this.loopID = null;
    this.lastTime = null;

    const world = Matter.World.create({ gravity: props.gravity });

    this.engine = Engine.create({
      world,
    });

    this.loop = this.loop.bind(this);
  }
github FormidableLabs / react-game-kit / src / components / world.js View on Github external
constructor(props) {
    super(props);

    this.loopID = null;
    this.lastTime = null;

    const world = Matter.World.create({ gravity: props.gravity });

    this.engine = Engine.create({
      world,
    });

    this.loop = this.loop.bind(this);
  }
github plinko-team / plinko / src / server / serverEngine.js View on Github external
socket.on('start game', () => {
        this.activeUsers.broadcastAll('start game');
        this.users.broadcastAll('game started');

        this.engine = Engine.create();
        this.createEnvironment();
        this.registerPhysicsEvents();

        setTimeout(() => {
          this.activeUsers.broadcastAll('START');
          this.startGame();
        }, 5000);
      });
github cyclegtx / colyseus-iog-state-sync / IOGStateSync / GameRoom.ts View on Github external
onInit (options: any) { 
        this.state = new GameState();
        this.setState(this.state);
        this.engine = Engine.create();
        this.engine.world.gravity.scale = 0;
        this.createWalls();
        
        Events.on(this.engine, "collisionStart", this.onCollisionStart.bind(this));
        Events.on(this.engine, "collisionEnd", this.onCollisionStart.bind(this));

        this.setSimulationInterval(this.update.bind(this));
        this.clock.setInterval(this.broadcastAllEntityIds.bind(this), 3000);
    }