Skip to content

Commit

Permalink
Merge pull request DefinitelyTyped#4204 from ivanegegia/master
Browse files Browse the repository at this point in the history
Type definitions for Victor.js 0.8.0 and Matter-js.js 0.2.0
  • Loading branch information
vvakame committed May 3, 2015
2 parents 1400e07 + e2bd29e commit 529c7d6
Show file tree
Hide file tree
Showing 5 changed files with 1,997 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ _infrastructure/tests/build
node_modules

.sublimets
.settings/launch.json
57 changes: 57 additions & 0 deletions matter-js/matter-js-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
///<reference path="matter-js.d.ts"/>

var Engine = Matter.Engine,
World = Matter.World,
Body = Matter.Body,
Bodies = Matter.Bodies,
Composites = Matter.Composites,
Constraint = Matter.Constraint,
Events = Matter.Events,
Query = Matter.Query


var engine = Engine.create(document.body)

//Bodies
var box1 = Bodies.rectangle(400,200,80,80)
var box2 = Bodies.rectangle(400,610,810,60, {
angle: 10,
angularSpeed: 11,
angularVelocity: 1,
density: 4,
isStatic: true
})

var circle1 = Bodies.circle(100,100,50)

World.addBody(engine.world, box1)
World.add(engine.world, [box2, circle1])


//Composites
var stack = Composites.stack(0, 100, 5, 1, 20, 0, function(x:number, y:number, column:number, row:number) {
return Bodies.circle(x, y, 75, { restitution: 0.9 });
});

World.add(engine.world, stack);

//Constraints
var constraint1 = Constraint.create({
bodyA: box1,
bodyB: box2,
stiffness: 0.02
})

//Query
var collisions = Query.ray([box1, box2, circle1], {x:1, y:2}, {x:3, y:4});

World.addConstraint(engine.world, constraint1)


//events
Events.on(engine, "beforeTick", (e:any)=>{

})


Engine.run(engine)
Loading

0 comments on commit 529c7d6

Please sign in to comment.