Skip to content

Commit

Permalink
Fixed fps display to work in FF, and tweaked readme
Browse files Browse the repository at this point in the history
  • Loading branch information
josephg committed Feb 2, 2013
1 parent 1984a46 commit da084d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ The API for Chipmunk-js is almost identical to chipmunk-physics. Except:
cpMomentForPoly(mass, numVerts, *verts, offset);
```

is now simply:
becomes:

```javascript
momentForPoly(mass, verts, offset);
cp.momentForPoly(mass, verts, offset);
```

- Lots of trivial getters and setters have been removed. Access the property directly.
- Lots of trivial getters and setters have been removed.

## On a website

Expand All @@ -39,7 +39,7 @@ space.addBody(new cp.Body(...))
</script>
```

If any exceptions are thrown or anything, use `cp.js` instead and post the stack trace you get to the issue page.
If any exceptions are thrown or anything, use `cp.js` instead of cp.min.js and post the stack trace you get to the issue page.

## From nodejs

Expand Down
22 changes: 9 additions & 13 deletions demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,18 @@ Demo.prototype.run = function() {
this.running = true;

var self = this;
var step = function() {
self.step();

var lastTime = 0;
var step = function(time) {
self.step(time - lastTime);
lastTime = time;

if (self.running) {
raf(step);
}
};

this.lastStep = Date.now();
step();
step(0);
};

var soon = function(fn) { setTimeout(fn, 1); };
Expand All @@ -252,13 +255,10 @@ Demo.prototype.stop = function() {
this.running = false;
};

Demo.prototype.step = function() {
var dt = (now - this.lastStep) / 1000;
this.lastStep = now;

Demo.prototype.step = function(dt) {
// Update FPS
if(dt > 0) {
this.fps = 0.7*this.fps + 0.3*(1/dt);
this.fps = 0.9*this.fps + 0.1*(1000/dt);
}

// Move mouse body toward the mouse
Expand All @@ -268,10 +268,6 @@ Demo.prototype.step = function() {

var lastNumActiveShapes = this.space.activeShapes.count;

// Limit the amount of time thats passed to 0.1 - if the user switches tabs or
// has a slow computer, we'll just slow the simulation down.
dt = Math.min(dt, 1/25);

var now = Date.now();
this.update(1/60);
this.simulationTime += Date.now() - now;
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!doctype html>
<!DOCTYPE HTML>
<style>
body {
margin: 0px;
Expand Down

0 comments on commit da084d8

Please sign in to comment.