Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
var scenarios = {
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
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;
// var engine = Engine.create();
jump(body) {
this.jumpNoise.play();
this.isJumping = true;
Matter.Body.applyForce(body, { x: 0, y: 0 }, { x: 0, y: -0.15 });
Matter.Body.set(body, 'friction', 0.0001);
};
componentWillReceiveProps(nextProps) {
if (this.props.rows !== nextProps.rows) {
const y = STAGE_HEIGHT / 2 + (nextProps.rows * this.state.height) + this.state.height / 2;
Matter.Body.setPosition(this.body, {x: this.state.x, y});
this.setState({ y });
}
}
}
move(body, x) {
Matter.Body.setVelocity(body, { x, y: 0 });
};
jump(body) {
this.jumpNoise.play();
this.isJumping = true;
Matter.Body.applyForce(body, { x: 0, y: 0 }, { x: 0, y: -0.15 });
Matter.Body.set(body, 'friction', 0.0001);
};
_.each(state.players, function(thisPlayer, playerId){
if(playerId != exclude){
var body = Matter.Body.create({
angle: thisPlayer.angle,
position: thisPlayer.position,
vertices: [{ x: -25, y: -25 }, { x: 0, y: 25 }, { x: 25, y: -25 }]
});
body.parentPlayer = self.getPlayer(playerId);
state.bodies.push(body);
}
});
}
"use strict";
/**
* A tool for inspecting worlds.
* @module Inspector
*/
const Inspector = module.exports = {};
const $ = require('jquery');
require('../../node_modules/jstree/dist/jstree.min');
const ToolsCommon = require('./Common');
const Serializer = require('matter-tools').Serializer;
const km = require('keymaster');
const Matter = require('matter-js');
const Body = Matter.Body;
const Bounds = Matter.Bounds;
const Composite = Matter.Composite;
const Common = Matter.Common;
const Events = Matter.Events;
const Mouse = Matter.Mouse;
const Query = Matter.Query;
const Vertices = Matter.Vertices;
const Vector = Matter.Vector;
const MouseConstraint = Matter.MouseConstraint;
var $body;
/**
* Creates an inspector
* @function Gui.create
* @param {engine} engine
update() {
const { onUpdate } = this.props;
if (onUpdate && typeof onUpdate === "function") {
const onUpdateResult = onUpdate(this.state);
if (onUpdateResult) {
this.setState((prevState) => {
return { ...prevState, ...onUpdateResult };
});
}
}
if (this.body.body) {
Matter.Body.setVelocity(this.body.body, { x: this.state.x, y: this.state.y });
}
}