Skip to content

Commit

Permalink
some optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Alerion committed Jul 10, 2011
1 parent 1a280c5 commit 6e6ddde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/static/js/jQuery.Game.Controller.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
left_button: null, left_button: null,
right_button: null, right_button: null,
bomb_button: null, bomb_button: null,
last_move_time: null,
constructor : function(config){ constructor : function(config){
jQuery.extend(this, config); jQuery.extend(this, config);
jQuery.Game.Controller.superclass.constructor.call(this, config); jQuery.Game.Controller.superclass.constructor.call(this, config);
Expand All @@ -21,6 +22,7 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
init: function(){ init: function(){
var that = this; var that = this;


this.last_move_time = +(new Date());
GameApi.load_players(this.initPlayers, this); GameApi.load_players(this.initPlayers, this);
this.map.on('cellclick', this.onCellClick, this); this.map.on('cellclick', this.onCellClick, this);
jQuery(document).keypress(function(event){return that.onKeyPress(event)}); jQuery(document).keypress(function(event){return that.onKeyPress(event)});
Expand Down Expand Up @@ -195,11 +197,13 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
this.createBomb(); this.createBomb();
return; return;
}; };

var td = +(new Date()) - this.last_move_time;
if ( ! this.player.isDead && this.canMove(cell)){
if ( ! this.player.isDead && this.canMove(cell) && (td >= MOVE_TIME*1000*0.8)){
GameApi.move(cell.x, cell.y, function(response){ GameApi.move(cell.x, cell.y, function(response){
if (response){ if (response){
this.player.setCell(cell); this.player.setCell(cell);
this.last_move_time = +(new Date());
} }
}, this); }, this);
} }
Expand Down
1 change: 1 addition & 0 deletions src/templates/main/base.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
STOMP_KEY = '{{ game.stomp_key }}'; STOMP_KEY = '{{ game.stomp_key }}';
ORBITED_STOMP_SOCKET = {{ ORBITED_STOMP_SOCKET }}; ORBITED_STOMP_SOCKET = {{ ORBITED_STOMP_SOCKET }};
ORBITED_HTTP_SOCKET = {{ ORBITED_HTTP_SOCKET }}; ORBITED_HTTP_SOCKET = {{ ORBITED_HTTP_SOCKET }};
MOVE_TIME = {{ MOVE_TIME }};


document.domain=document.domain; document.domain=document.domain;
Orbited.settings.port = ORBITED_HTTP_SOCKET; Orbited.settings.port = ORBITED_HTTP_SOCKET;
Expand Down

0 comments on commit 6e6ddde

Please sign in to comment.