Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

looked into odd restart bug

  • Loading branch information...
commit cd818a1dced383a4985ad917c88dbe6414604428 1 parent a3afb94
@MrJaba authored
View
1  .bundle/config
@@ -1,2 +1,3 @@
---
BUNDLE_WITHOUT: ""
+BUNDLE_PATH: ruby-debug
View
3  Gemfile
@@ -11,4 +11,5 @@ gem 'i18n', "0.3.3"
gem "eventmachine", "0.12.10"
gem 'usher'
gem "uuid"
-gem "json"
+gem "json"
+gem 'ruby-debug'
View
3  controllers/game_controller.rb
@@ -1,7 +1,8 @@
+require 'ruby-debug'
class GameController < Cramp::Controller::Websocket
periodic_timer :push_states, :every => 0.05
periodic_timer :push_bombs, :every => 0.05
- periodic_timer :cleanup, :every => 1
+ #periodic_timer :cleanup, :every => 1
on_data :receive_message
class << self
attr_accessor :player_states
View
17 public/javascripts/game.js
@@ -166,8 +166,8 @@ MrJaba.Bomberman = function(){
delete MrJaba.Bomberman.explosions[explosion.getId()];
},
- addBomb:function(uuid, bomb){
- MrJaba.Bomberman.bombs[uuid] = bomb;
+ addBomb:function(bomb){
+ MrJaba.Bomberman.bombs[bomb.getId()] = bomb;
},
updateOpponentPositions: function(positions){
@@ -178,6 +178,7 @@ MrJaba.Bomberman = function(){
var li_class = ( uuid === MrJaba.Bomberman.uuid ) ? "me" : "opponent"
$("#scores").prepend("<li class='"+li_class+"'><span class='score'>"+position.score+"</span><span class='uuid'>"+uuid+"</span></li>");
})
+ //remove opponents that have timed out
var tmpOpponents = MrJaba.Bomberman.opponents;
$.each(tmpOpponents, function(uuid, position){
if(positions[uuid] === undefined){
@@ -202,12 +203,12 @@ MrJaba.Bomberman = function(){
},
updateBombPositions: function(positions){
- $.each(positions, function(uuid, position){
- if(MrJaba.Bomberman.bombs[uuid] === undefined && MrJaba.Bomberman.explosions[uuid] === undefined){
+ $.each(positions, function(bombId, bomb){
+ if(MrJaba.Bomberman.bombs[bombId] === undefined && MrJaba.Bomberman.explosions[bombId] === undefined){
var protoSprite = new Sprite();
- protoSprite.initialize(uuid, MrJaba.Bomberman.Images.getImage('Bomb'), MrJaba.Bomberman.canvas);
- var bomb = $.extend(protoSprite, new Bomb(position['x'], position['y']));
- MrJaba.Bomberman.bombs[uuid] = bomb;
+ protoSprite.initialize(bombId, MrJaba.Bomberman.Images.getImage('Bomb'), MrJaba.Bomberman.canvas);
+ var bomb = $.extend(protoSprite, new Bomb(bomb['x'], bomb['y']));
+ MrJaba.Bomberman.bombs[bombId] = bomb;
}
})
},
@@ -222,7 +223,7 @@ MrJaba.Bomberman = function(){
MrJaba.Bomberman.canvas = initCanvas();
MrJaba.Bomberman.me = $.extend(new Player(), initCharacter('me'));
MrJaba.Bomberman.opponents = {};
- MrJaba.Bomberman.bombs = {};
+ MrJaba.Bomberman.bombs = {}
MrJaba.Bomberman.explosions = {};
$(document).trigger('initDone');
setInterval( runGameLoop, 100 );
View
2  public/javascripts/player.js
@@ -5,7 +5,7 @@ Player.prototype = {
var protoSprite = new Sprite();
protoSprite.initialize(MrJaba.Bomberman.uuid, MrJaba.Bomberman.Images.getImage('Bomb'), this.canvas );
var bomb = $.extend(protoSprite, new Bomb(this.x, this.y));
- MrJaba.Bomberman.addBomb(MrJaba.Bomberman.uuid, bomb);
+ MrJaba.Bomberman.addBomb(bomb);
},
setImage:function(newImage){
Please sign in to comment.
Something went wrong with that request. Please try again.