Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Inside Rawkets - onGameStart

robhawkes
September 23, 2011

Inside Rawkets - onGameStart

Rawkets presentation from onGameStart 2011 in Poland.

robhawkes

September 23, 2011
Tweet

More Decks by robhawkes

Other Decks in Programming

Transcript

  1. types = { PING: 1, SYNC: 2, SYNC_COMPLETED: 3, NEW_PLAYER:

    4, UPDATE_PLAYER: 5, UPDATE_INPUT: 6, REMOVE_PLAYER: 7 }; Enumeration
  2. { z: 1, id: 1234567890, t: 1316763202872, s: { x:

    5, y: 34, v: 3, a: 0.46 } } Message package
  3. 1 4 4 1 1 4 4 1 MESSAGES IN

    4 MESSAGES OUT 16
  4. (function() { var rawkets = rawkets || {}, r =

    rawkets; rawkets.namespace = function(namespace_str) { var parts = namespace_str.split("."), parent = rawkets, i; if (parts[0] === "rawkets") { parts = parts.slice(1); }; for (i = 0; i < parts.length; i++) { if (typeof parent[parts[i]] === "undefined") { parent[parts[i]] = {}; }; parent = parent[parts[i]]; }; return parent; }; window.rawkets = window.r = rawkets; })(window);
  5. var correction = function(time, state, input, entity, rk4) { ...

    if (Math.abs(state.x - lastMove.state.x) > 2) { ... var currentTime = time, currentInput = input; entity.setState(state); // Rewind entity state var move, // Current move frameTime; // Time between correction and stored move for (m = 0; m < moveCount; m++) { move = moves[m]; frameTime = (move.time - currentTime) / 1000; // Update physics based on corrected time, input and state ... currentTime = move.time; currentInput = move.input; move.state = entity.getState(); }; }; };
  6. check host rawkets.com with address 127.0.0.1 start program = "/etc/init.d/rawkets

    start" stop program = "/etc/init.d/rawkets stop" if failed port 8000 type tcp for 2 times within 3 cycles then restart Monit script
  7. #!/bin/sh case "$1" in start) cd /rawkets /usr/local/bin/node rawkets.js 2>&1

    >> /var/log/node.log & exit 1 ;; stop) /usr/bin/pkill -f 'node rawkets.js' exit 1 ;; esac exit 1 Init.d script
  8. Rob Hawkes Rawkets.com HTML5 & WebSockets game Twitter sentiment analysis

    Delving into your soul RECENT PROJECTS Rawkes.com Personal website and blog MORE COOL STUFF ExplicitWeb.co.uk Web development podcast Rawket Scientist Technical Evangelist at Mozilla @robhawkes
  9. Become a canvas master RAWKES.COM/FOUNDATIONCANVAS Out now Paperback and digital

    formats Learn how to animate Make two cool space games Foundation HTML5 Canvas
  10. November is HTML5 canvas Every month Next month is CSS

    Media Queries Win prizes (like an Android) DEVELOPER.MOZILLA.ORG/EN-US/DEMOS/DEVDERBY Mozilla Dev Derby
  11. Hand-picked experts @ASKMDN & #ASKMDN ON TWITTER One hour every

    fortnight Web development topics Great discussions Ask MDN ASKMDN onGameStart special (hopefully)