kippy 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -297,7 +297,7 @@ To be added, for now use web's built-in `Audio` class.
297
297
 
298
298
  ### Sleep system
299
299
 
300
- When a body's velocity is too low for too long, the body will enter sleep state, which means its position will not be affected by the physics engine until a force is applied or a collision happens, this is to prevent jittering and optimize performance.
300
+ When a body's velocity is too low for too long, the body will enter sleep state, which means its position will not be affected by the physics engine until a force is applied, a collision happens, or the velocity is above threshold again, this is to prevent jittering and optimize performance.
301
301
 
302
302
  You can configure it inside `RigidBody`:
303
303
  ```js
package/dist/game.js CHANGED
@@ -43,8 +43,6 @@ export class Game {
43
43
  const dt = (timestamp - this.lastTime) / 1000;
44
44
  this.lastTime = timestamp;
45
45
  if (this.scene) {
46
- // Update input info
47
- this.input.update();
48
46
  // Update game logic
49
47
  this.scene.update(dt);
50
48
  // Update physics info
@@ -52,6 +50,8 @@ export class Game {
52
50
  // Render
53
51
  this.ctx.clearRect(0, 0, this.ctx.canvas.width, this.ctx.canvas.height);
54
52
  this.scene.render();
53
+ // Update input info
54
+ this.input.update();
55
55
  }
56
56
  else {
57
57
  throw new Error("Can not run game loop without a scene");
package/dist/physics.js CHANGED
@@ -163,8 +163,11 @@ export class Physics {
163
163
  // Update velocity/apply force
164
164
  for (const entity of entities) {
165
165
  if (entity.body instanceof RigidBody) {
166
- // Wake if force applied
167
- if (entity.body.force.magnitudeSquared() > 0 || entity.body.torque !== 0) {
166
+ // Wake if force applied or velocity above threshold
167
+ if (entity.body.force.magnitudeSquared() > 0 ||
168
+ entity.body.torque !== 0 ||
169
+ entity.body.velocity.magnitudeSquared() > entity.body.sleepThreshold ** 2 ||
170
+ Math.abs(entity.body.rotationVelocity) > entity.body.sleepThreshold) {
168
171
  entity.body.wake();
169
172
  }
170
173
  // Skip sleeping bodies with no forces
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kippy",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Kippy 2D web game engine for JS",
5
5
  "keywords": [
6
6
  "kippy",