Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed scrolling problem

  • Loading branch information...
commit 3737a5cfbcfefda320dc91c10f77a6c1a3f9d594 1 parent fe367a5
Stuart Campbell authored
Showing with 11 additions and 6 deletions.
  1. 0  .monitor
  2. +11 −6 public/js/game/client.js
View
0  .monitor
No changes.
View
17 public/js/game/client.js
@@ -20,6 +20,7 @@ KaboomClient.prototype = {
onKeyDown : function(event){
+ console.log('keydown');
var player = window.player;
var key = $.hotkeys.specialKeys[event.which] || String.fromCharCode(event.which).toLowerCase();
@@ -44,10 +45,12 @@ KaboomClient.prototype = {
if (playerChanged)
this.notifyPlayerChanged();
+ return false;
},
onKeyUp : function(event){
+ console.log('keyup');
var player = window.player;
var key = $.hotkeys.specialKeys[event.which] || String.fromCharCode(event.which).toLowerCase();
@@ -63,9 +66,11 @@ KaboomClient.prototype = {
}
this.notifyPlayerChanged();
+ return false;
},
+
notifyPlayerChanged: function(){
this.socket.playerChangedDirection(player);
},
@@ -87,10 +92,10 @@ KaboomClient.prototype = {
console.log('Creating game...');
window.game = new KaboomGame();
window.game.copyStateFrom(gameState);
+
window.player = window.game.findPlayer(playerState);
-
- $(document).bind('keydown', this.onKeyDown.bind(this));
- $(document).bind('keyup', this.onKeyUp.bind(this));
+ $(document).bind('keydown', this.onKeyDown.tie(this));
+ $(document).bind('keyup', this.onKeyUp.tie(this));
var renderingTargets = {
arena: $('#arena'),
@@ -111,7 +116,7 @@ KaboomClient.prototype = {
};
-Function.prototype.bind = function () {
+Function.prototype.tie = function () {
if (arguments.length < 2 && arguments[0] === undefined) {
return this;
@@ -130,8 +135,8 @@ Function.prototype.bind = function () {
-Function.bind = function () {
+Function.tie = function () {
var args = Array.prototype.slice.call(arguments);
- return Function.prototype.bind.apply(args.shift(), args);
+ return Function.prototype.tie.apply(args.shift(), args);
}
Please sign in to comment.
Something went wrong with that request. Please try again.