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
var Projectile = require('../Projectile') | |
var Vector2 = require('../../../nengi/Vector2') | |
var Map = require('../../map/Map') | |
var WallType = require('../../map/WallType') | |
describe('Projectile', function() { | |
var projectile = null | |
var mockClient = null | |
var mockTarget = null | |
var mockWeapon = null |
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
var BinarySerializer = require('../binary/BinarySerializer') | |
var BinaryType = require('../binary/BinaryType') | |
// axis-aligned bounding box | |
/* PARAMS: (Point)center, (Point)half */ | |
function AABB(x, y, halfWidth, halfHeight) { | |
this.initialize(x, y, halfWidth, halfHeight) | |
} | |
AABB.pool = [] |
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
var Existence = require('../Existence') | |
describe('Existence', function() { | |
var existence = null | |
beforeEach(function() { | |
existence = new Existence() | |
}) | |
it('can add/getById entities', function() { |
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
// nengi client side! | |
var nengi = require('../../nengi/nengi') | |
var common = require('../common') | |
var app = new nengi.Application(common) | |
app.shouldEmitGameState = true | |
// actions | |
var Move = require('./input/Move') | |
var Attack = require('./input/Attack') |
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
var EventEmitter = require('../../nengi/external/EventEmitter') | |
function InputManager() { | |
EventEmitter.call(this) | |
// tracks the real time state of W A S D | |
this.W = false | |
this.A = false | |
this.S = false | |
this.D = false |
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
// Keying | |
var BinaryType = { | |
/* basic binary types */ | |
Int8: 0, // signed integer | |
UInt8: 1, // unsigned integer | |
/* skipped a dozen other basic binary types */ | |
/* fancy or custom binary types */ |
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
var nengi = require('../../nengi/nengi') | |
var Vector2 = nengi.Vector2 | |
function PhysicsComponent(gameObject, config) { | |
nengi.Component.call(this, gameObject, config) | |
// force applied from external sources | |
this.externalForce = new Vector2() |
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
var BitBuffer = function(sourceOrLength) { | |
this.bitLength = null // length in bits (can be less than the bytes/8) | |
this.byteLength = null // length in bytes (atleast enough to hold the bits) | |
this.byteArray = null // Uint8Array holding the underlying bits and bytes | |
//console.log('BitBuffer ctor', sourceOrLength, typeof sourceOrLength) | |
if (typeof sourceOrLength === 'number') { | |
// create a bitBuffer with *length* bits | |
this.bitLength = sourceOrLength |
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
// specify which properties should be networked, and their value types | |
Hero.prototype.netSchema = nengi.BinarySerializer.createSchema({ | |
'id': nengi.UInt16, | |
'type': nengi.UInt8, | |
'x': nengi.Int16, | |
'y': nengi.Int16, | |
'hp': nengi.UInt8, | |
}, { | |
'x': { delta: true, binaryType: nengi.Int8 }, | |
'y': { delta: true, binaryType: nengi.Int8 } |
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
function compareNumbers(a, b) { | |
return a - b | |
} | |
function arrayDiffs(a, b) { | |
a.sort(compareNumbers) | |
b.sort(compareNumbers) | |
//console.log('A', a) | |
//console.log('B', b) |