Created
November 16, 2019 11:51
-
-
Save garganurag893/c617ac5512479b2243e6dc4d95be0dc7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Plane from '../components/Plane'; | |
import Matter from 'matter-js'; | |
Matter.Common.isElement = () => false; //-- Overriding this function because the original references HTMLElement | |
export default restart => { | |
//-- Cleanup existing entities.. | |
if (restart) { | |
Matter.Engine.clear(restart.physics.engine); | |
} | |
let engine = Matter.Engine.create({enableSleeping: false}); | |
let world = engine.world; | |
world.gravity.y = 0.25; | |
const boxSize = 50; | |
return { | |
physics: {engine: engine, world: world}, | |
Plane: Plane( | |
world, | |
'pink', | |
{x: 220, y: 400}, | |
{height: boxSize, width: boxSize}, | |
), | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment