From 353e5330ce4061eb22ef82a707a1d3af78c78f34 Mon Sep 17 00:00:00 2001 From: onedayitwillmake Date: Wed, 11 May 2011 22:32:47 -0400 Subject: [PATCH] Cleaned up FieldController dealloc --- js/BubbleDots/BubbleDotsConstants.js | 2 +- js/BubbleDots/BubbleDotsServerGame.js | 2 +- js/BubbleDots/entities/PlayerEntity.js | 2 +- js/BubbleDots/traits/ChaseTrait.js | 2 +- js/BubbleDots/traits/FoodTrait.js | 3 ++- js/controller/FieldController.js | 16 +++++----------- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/js/BubbleDots/BubbleDotsConstants.js b/js/BubbleDots/BubbleDotsConstants.js index 0866d4f..5e44427 100644 --- a/js/BubbleDots/BubbleDotsConstants.js +++ b/js/BubbleDots/BubbleDotsConstants.js @@ -19,7 +19,7 @@ Version: ENTITY_DEFAULT_RADIUS : 17, GAME_WIDTH : 700, GAME_HEIGHT : 450, - MAX_CIRCLES : 40, + MAX_CIRCLES : 200, GAME_DURATION : 1000*300, ENTITY_TYPES: { diff --git a/js/BubbleDots/BubbleDotsServerGame.js b/js/BubbleDots/BubbleDotsServerGame.js index 60872b5..d0b4209 100644 --- a/js/BubbleDots/BubbleDotsServerGame.js +++ b/js/BubbleDots/BubbleDotsServerGame.js @@ -73,7 +73,7 @@ Version: var entity = this.createEntity( BubbleDots.CircleEntity, radius, this.getNextEntityID(), RealtimeMultiplayerGame.Constants.SERVER_SETTING.CLIENT_ID ); // Randomly make the object 'food' or 'poison' - if(i%3 === 0) { + if(i%10 === 0) { entity.addTraitAndExecute( new BubbleDots.traits.PoisonTrait() ); } else { entity.addTraitAndExecute( new BubbleDots.traits.FoodTrait() ); diff --git a/js/BubbleDots/entities/PlayerEntity.js b/js/BubbleDots/entities/PlayerEntity.js index 73e24d9..7629232 100644 --- a/js/BubbleDots/entities/PlayerEntity.js +++ b/js/BubbleDots/entities/PlayerEntity.js @@ -33,7 +33,7 @@ var count = 0; handleInput: function( speedFactor ) { var moveSpeed = 0.3; - if( this.input.isLeft() ) this.acceleration.x -= moveSpeed; + if( this.input.isLeft() ) this.acceleration.x -= moveSpeed*2.1; if( this.input.isRight() ) this.acceleration.x += moveSpeed; if( this.input.isUp() ) this.acceleration.y -= moveSpeed; if( this.input.isDown() ) this.acceleration.y += moveSpeed; diff --git a/js/BubbleDots/traits/ChaseTrait.js b/js/BubbleDots/traits/ChaseTrait.js index 6e49634..f2139dd 100644 --- a/js/BubbleDots/traits/ChaseTrait.js +++ b/js/BubbleDots/traits/ChaseTrait.js @@ -37,7 +37,7 @@ Abstract: */ execute: function() { RATE += 0.3; - this.radius = Math.random() * 20 + 5; + this.radius = Math.random() * 20 + 10; this.offset = new RealtimeMultiplayerGame.model.Point( Math.cos(RATE) * this.radius, Math.sin(RATE) * -this.radius); this.chaseSpeed = Math.random() * 0.02 + 0.001; BubbleDots.traits.ChaseTrait.superclass.execute.call(this); diff --git a/js/BubbleDots/traits/FoodTrait.js b/js/BubbleDots/traits/FoodTrait.js index 5ec9615..cbac855 100644 --- a/js/BubbleDots/traits/FoodTrait.js +++ b/js/BubbleDots/traits/FoodTrait.js @@ -55,7 +55,7 @@ Abstract: BubbleDots.lib.TWEEN.remove( me._tween ); me._tween = new BubbleDots.lib.TWEEN.Tween({radius: me.radius}) - .to({radius: 5}, 250) + .to({radius: 2}, 500) .easing(BubbleDots.lib.TWEEN.Easing.Back.EaseInOut) .onUpdate(function(){ me.setRadius(~~this.radius); @@ -67,6 +67,7 @@ Abstract: // them.collisionCircle.setRadius( newRadius ); me.collisionCircle.collisionGroup = 0; // me.acceleration.translatePoint( collisionNormal.multiply(-10) ); + var chaseTrait = this.addTraitAndExecute( new BubbleDots.traits.ChaseTrait() ); chaseTrait.setTarget( them ); // me.tempColor(); diff --git a/js/controller/FieldController.js b/js/controller/FieldController.js index 4cf9802..0e3cb4b 100644 --- a/js/controller/FieldController.js +++ b/js/controller/FieldController.js @@ -133,27 +133,21 @@ }, - dealloc: function() - { - this.isDeallocated = true; - + dealloc: function() { this.players.forEach( function(key, entity){ this.removePlayer(entity.clientid); }, this ); + this.players.dealloc(); + this.players = null; this.entities.forEach( function(key, entity){ this.removeEntity(entity.entityid); }, this ); - - this.entities.dealloc(); - this.players.dealloc(); + this.entities = null; - this.view = null; - delete this.view; - delete this.players; - delete this.entities; + this.view = null; }, ///// Accessors