Giter VIP home page Giter VIP logo

timeline's Introduction

@gamestdio/timeline Build Status

Greenkeeper badge

Timelines implementation for lag compensation techniques in networked games. Use it both on server and/or client-side according to your needs.

  • Take snapshots of game state
  • Interpolates and extrapolates values based on snapshots taken.

API

  • createTimeline([ maxSnapshots=10 ]) - Create a Timeline instance
  • Timeline#takeSnapshot( state[, elapsedMs ] ) - Record state on timeline history
  • Timeline#at( elapsedMs[, interpolate=true ] ) - Get Proxy object containing interpolated values between recorded states.
  • Timeline#offset( elapsedMs[, interpolate=true ] ) - Same as #at, but from the last snapshot taken.

Example

import { createTimeline } from '@gamestdio/timeline'

var timeline = createTimeline()

// first game state snapshot
timeline.takeSnapshot({
  player: { x: 100 },
  enemy: { x: 0 }
})

setTimeout(() => {
  // take second game state snapshot after 1000ms

  timeline.takeSnapshot({
    player: { x: 0 },
    enemy: { x: 100 }
  })

  //
  // Retrieving a previous state
  //
  console.log( timeline.at( 0 ).player.x )
  // => 100
  console.log( timeline.at( 0 ).enemy.x )
  // => 0

  //
  // Interpolating data from known states
  //
  console.log( timeline.at( 500 ).player.x )
  // => 49.75124378109453
  console.log( timeline.at( 500 ).enemy.x )
  // => 50.24875621890547

  //
  // Extrapolating data between an unknown state
  //
  console.log( timeline.at( 1500 ).player.x )
  // => -49.25373134328358
  console.log( timeline.at( 1500 ).enemy.x )
  // => 149.2537313432836

}, 1000)

To execute this example run the following command:

node --harmony --harmony-proxies example/usage.js

References

License

MIT

timeline's People

Contributors

darkyen avatar endel avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

timeline's Issues

Add benchmarks?

Can you add benchmarks of this, not really a big thing but it should set expectations of a general of how big of a state can be/should be interpolated. This will also allow better understanding the impact of an interpolation / extrapolation algorithm which will consider all previous states.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

how to use it ?

I don't find the code that relative with timeline in font-end code ,so I haven't figure it out how to use the timeline. I don't know how the font-end code run with back-end code by timeline .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.