-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/onedayitwillmake/Realtime…
- Loading branch information
Showing
22 changed files
with
273 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
File: | ||
BoundaryTrait.js | ||
Created By: | ||
Mario Gonzalez | ||
Project : | ||
RealtimeMultiplayerNodeJS | ||
Abstract: | ||
This trait will cause an entity to react to boundary collisions | ||
Basic Usage: | ||
*/ | ||
(function(){ | ||
BubbleDots.namespace("BubbleDots.traits"); | ||
BubbleDots.traits.BoundaryTrait = function( aCollisionManager ) { | ||
BubbleDots.traits.BoundaryTrait.superclass.constructor.call(this); | ||
this._collisionManager = aCollisionManager; | ||
}; | ||
|
||
BubbleDots.traits.BoundaryTrait.prototype = { | ||
displayName : "BoundaryTrait", // Unique string name for this Trait | ||
_boundaryRule : 0, | ||
_collisionManager : null, | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
attach: function(anEntity) { | ||
BubbleDots.traits.BoundaryTrait.superclass.attach.call(this, anEntity); | ||
this.intercept(['updatePosition']); | ||
}, | ||
|
||
/** | ||
* Intercepted properties | ||
*/ | ||
updatePosition: function( speedFactor, gameClock, gameTick ) { | ||
var trait = this.getTraitWithName("BoundaryTrait"); | ||
|
||
// Call the original handleAcceleration | ||
trait._collisionManager.handleBoundaryForCircle( this.getCollisionCircle(), trait._boundaryRule ); | ||
trait.interceptedProperties._data.updatePosition.call(this, speedFactor, gameClock, gameTick); | ||
}, | ||
|
||
detach: function( force ) { | ||
this._collisionManager = null; | ||
BubbleDots.traits.BoundaryTrait.superclass.detach.call(this, force); | ||
}, | ||
|
||
///// ACCESSORS | ||
/** | ||
* Set the gravitational force | ||
* @param {Number} aBoundaryRule Boundary rule to apply to collision circle, see CollisionManager | ||
*/ | ||
setBoundaryRule: function( aBoundaryRule ) { | ||
this._boundaryRule = aBoundaryRule; | ||
return this; | ||
} | ||
}; | ||
|
||
// Extend BaseTrait | ||
RealtimeMultiplayerGame.extend( BubbleDots.traits.BoundaryTrait, RealtimeMultiplayerGame.controller.traits.BaseTrait ); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.