Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function () {
// module aliases
var Engine = Matter.Engine,
World = Matter.World,
Bodies = Matter.Bodies,
Body = Matter.Body;
var Hockey = {}
Hockey.create = function(env) {
var self = {}; // instance of the Hockey class
// these should not be mutated
var params = {show: false,
num_obj: 3,
cx: 400, // 640
cy: 300, // 480
max_v0: 20,
obj_radius: 50 };
self.params = params;
import * as Matter from 'matter-js'
// Matter.js module aliases
const consts = {
Engine: Matter.Engine,
World: Matter.World,
Body: Matter.Body,
Bodies: Matter.Bodies,
Events: Matter.Events,
Vector: Matter.Vector,
Composite: Matter.Composite
}
export default consts
var Matter = require('matter-js')
var jsonfile = require('jsonfile')
var _ = require('underscore')
require('./demo/js/Examples')
// module aliases
var Engine = Matter.Engine,
World = Matter.World,
Bodies = Matter.Bodies,
Body = Matter.Body,
Example = Matter.Example;
// some example engine options
var engine_options = {
positionIterations: 6,
velocityIterations: 4,
enableSleeping: false,
metrics: { extended: true }
};
var env = {}
env.engine = Engine.create(engine_options);
// 木偶人对战画面, 效率太低, 废弃;
let Matter = require('matter-js');
var Engine = Matter.Engine,
Render = Matter.Render,
Runner = Matter.Runner,
Body = Matter.Body,
Constraint = Matter.Constraint,
MouseConstraint = Matter.MouseConstraint,
Mouse = Matter.Mouse,
World = Matter.World,
Bodies = Matter.Bodies,
Composites = Matter.Composites,
Composite = Matter.Composite,
Events = Matter.Events;
Composites.Person = function(x, y, ){
let group = Body.nextGroup(true),
Person = Composite.create({ label: 'Person'}),
radius = 2;
var options = {
collisionFilter: {
group: group
},
chamfer : {
radius: 4
}
physicsInit(engine) {
const ground = Matter.Bodies.rectangle(512 * 3, 448, 1024 * 3, 64, {
isStatic: true,
});
const leftWall = Matter.Bodies.rectangle(-64, 288, 64, 576, {
isStatic: true,
});
const rightWall = Matter.Bodies.rectangle(3008, 288, 64, 576, {
isStatic: true,
});
Matter.World.addBody(engine.world, ground);
Matter.World.addBody(engine.world, leftWall);
Matter.World.addBody(engine.world, rightWall);
};
export const addPipesAtLocation = (x, world, entities) => {
let [pipe1Height, pipe2Height] = generatePipes();
let pipeTopWidth = Constants.PIPE_WIDTH + 20;
let pipeTopHeight = (pipeTopWidth / 205) * 95;
pipe1Height = pipe1Height - pipeTopHeight;
let pipe1Top = Matter.Bodies.rectangle(
x,
pipe1Height + (pipeTopHeight / 2),
pipeTopWidth,
pipeTopHeight,
{ isStatic: true}
);
let pipe1 = Matter.Bodies.rectangle(
x,
pipe1Height / 2,
Constants.PIPE_WIDTH,
pipe1Height,
{ isStatic: true}
);
pipe2Height = pipe2Height - pipeTopHeight;
/**
* A tool for modifying the properties of an engine and renderer.
* @module Gui
*/
var Gui = module.exports = {};
const dat = require('../../node_modules/dat.gui/build/dat.gui.min');
const ToolsCommon = require('./Common');
const Serializer = require('matter-tools').Serializer;
const Matter = require('matter-js');
const Engine = Matter.Engine;
const Detector = Matter.Detector;
const Grid = Matter.Grid;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Events = Matter.Events;
const Composite = Matter.Composite;
/**
* Creates a Gui
* @function Gui.create
* @param {engine} [engine]
* @param {runner} [runner]
* @param {render} [render]
* @return {gui} The created gui instance
*/
Gui.create = function(engine, runner, render) {
dat.GUI.TEXT_CLOSED = '▲';
dat.GUI.TEXT_OPEN = '▼';
var datGui = new dat.GUI({ autoPlace: false });
value: function createPhysics(_ref2) {
var width = _ref2.width,
height = _ref2.height;
var options = {
restitution: _bodies.WALL_RESTITUTION,
friction: _bodies.WALL_FRICTION
};
this.body = _matterJs.Bodies.rectangle(this.x, this.y, this.width, this.height, options);
this.body.isStatic = true;
this.body.position.x = this.x;
this.body.position.y = this.y;
this.body.label = this.type;
}
}, {
setupWorld = () => {
let engine = Matter.Engine.create({ enableSleeping: false });
let world = engine.world;
world.gravity.y = 0.0;
let bird = Matter.Bodies.rectangle( Constants.MAX_WIDTH / 2, Constants.MAX_HEIGHT / 2, Constants.BIRD_WIDTH, Constants.BIRD_HEIGHT);
let floor1 = Matter.Bodies.rectangle(
Constants.MAX_WIDTH / 2,
Constants.MAX_HEIGHT - 25,
Constants.MAX_WIDTH + 4,
50,
{ isStatic: true }
);
let floor2 = Matter.Bodies.rectangle(
Constants.MAX_WIDTH + (Constants.MAX_WIDTH / 2),
Constants.MAX_HEIGHT - 25,
Constants.MAX_WIDTH + 4,
50,
{ isStatic: true }
);
setupWorld = () => {
let engine = Matter.Engine.create({ enableSleeping: false });
let world = engine.world;
world.gravity.y = 0.0;
let bird = Matter.Bodies.rectangle( Constants.MAX_WIDTH / 2, Constants.MAX_HEIGHT / 2, Constants.BIRD_WIDTH, Constants.BIRD_HEIGHT);
let floor1 = Matter.Bodies.rectangle(
Constants.MAX_WIDTH / 2,
Constants.MAX_HEIGHT - 25,
Constants.MAX_WIDTH + 4,
50,
{ isStatic: true }
);
let floor2 = Matter.Bodies.rectangle(
Constants.MAX_WIDTH + (Constants.MAX_WIDTH / 2),
Constants.MAX_HEIGHT - 25,
Constants.MAX_WIDTH + 4,
50,
{ isStatic: true }
);