freerider-trackcode-parser
Streaming parser for Free Rider track codes.
Last updated 3 years ago by goto-bus-stop .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install freerider-trackcode-parser 
SYNC missed versions from official npm registry.

freerider-trackcode-parser

A streaming parser for Free Rider trackcodes, like those used by CanvasRider.

Usage

var got = require('got').stream
var parser = require('freerider-trackcode-parser')

var request = got.post('http://canvasrider.com/js/load.php', {
  body: {
    track: 1463046
  }
})

request.pipe(parser()).on('data', function (op) {
  switch (op.type) {
  case 'line':
    // a line from
    [op.start.x, op.start.y];
    // to
    [op.end.x, op.end.y];
    break
  case 'scenery':
    // a scenery line from
    [op.start.x, op.start.y];
    // to
    [op.end.x, op.end.y];
    break
  case 'powerup':
    // a powerup of type
    op.powerup // 'B', 'G', 'O', 'C', 'S', 'T'
    // at
    [op.position.x, op.position.y];
    // and if the type is 'B' or 'G',
    op.direction // in degrees
    break
  case 'vehicle':
    // the default vehicle type
    op.vehicle
    break
  case 'time':
    // the fastest finish time so far
    op.time
    break
  }
})

License

MIT

Current Tags

  • 1.0.0                                ...           latest (3 years ago)

1 Versions

  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (2)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |