Permalink
Browse files

some optimization

  • Loading branch information...
Alerion committed Jul 10, 2011
1 parent 1a280c5 commit 6e6ddde173c266a75edbd789931de5b51e6c26a8
Showing with 7 additions and 2 deletions.
  1. +6 −2 src/static/js/jQuery.Game.Controller.js
  2. +1 −0 src/templates/main/base.html
@@ -13,6 +13,7 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
left_button: null,
right_button: null,
bomb_button: null,
+ last_move_time: null,
constructor : function(config){
jQuery.extend(this, config);
jQuery.Game.Controller.superclass.constructor.call(this, config);
@@ -21,6 +22,7 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
init: function(){
var that = this;
+ this.last_move_time = +(new Date());
GameApi.load_players(this.initPlayers, this);
this.map.on('cellclick', this.onCellClick, this);
jQuery(document).keypress(function(event){return that.onKeyPress(event)});
@@ -195,11 +197,13 @@ jQuery.Game.Controller = jQuery.inherit(jQuery.util.Observable, {
this.createBomb();
return;
};
-
- if ( ! this.player.isDead && this.canMove(cell)){
+ var td = +(new Date()) - this.last_move_time;
+
+ if ( ! this.player.isDead && this.canMove(cell) && (td >= MOVE_TIME*1000*0.8)){
GameApi.move(cell.x, cell.y, function(response){
if (response){
this.player.setCell(cell);
+ this.last_move_time = +(new Date());
}
}, this);
}
@@ -25,6 +25,7 @@
STOMP_KEY = '{{ game.stomp_key }}';
ORBITED_STOMP_SOCKET = {{ ORBITED_STOMP_SOCKET }};
ORBITED_HTTP_SOCKET = {{ ORBITED_HTTP_SOCKET }};
+ MOVE_TIME = {{ MOVE_TIME }};
document.domain=document.domain;
Orbited.settings.port = ORBITED_HTTP_SOCKET;

0 comments on commit 6e6ddde

Please sign in to comment.