You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

game.js 651B

123456789101112131415161718192021222324252627
  1. (function() {
  2. window.Game = function(canvas, players, index) {
  3. this._canvas = canvas;
  4. this._ctx = canvas.getContext("2d");
  5. this._players = players;
  6. this._player = players[index];
  7. this._sock = sock;
  8. this._keys = [];
  9. //Keep track of which keys are pressed and which aren't
  10. canvas.addEventListener("keydown", function(evt) {
  11. this._keys[evt.keyCode] = true;
  12. }.bind(this));
  13. canvas.addEventListener("keyup", function(evt) {
  14. this._keys[evt.keyCode] = false;
  15. }.bind(this));
  16. }
  17. Game.prototype.start = function() {
  18. console.log("starting game");
  19. }
  20. Game.prototype.stop = function() {
  21. console.log("Stopping game");
  22. }
  23. })();