1
0
Fork 0

Shorthand method definitions

babel
Mike Gerwitz 2015-12-24 00:42:24 -05:00
parent a731325461
commit c9df9f439e
18 changed files with 173 additions and 173 deletions

View File

@ -42,43 +42,43 @@ module.exports = Class( 'ClassicGame' )
* LTG loader
* @type {LtgLoader}
*/
'private _ltgLoader': null,
_ltgLoader: null,
/**
* Tile masker
* @type {TileMasker}
*/
'private _masker': null,
_masker: null,
/**
* Tiles
* @type {Object.<Object>}
*/
'private _tileSet': null,
_tileSet: null,
/**
* Set of available levels
* @type {LevelSet}
*/
'private _levelSet': null,
_levelSet: null,
/**
* Event handlers
* @type {Object.<Function>}
*/
'private _callback': {},
_callback: {},
/**
* Performs level rendering
* @type {LevelRender}
*/
'private _render': null,
_render: null,
/**
* Classic game object factory
* @type {ClassicGameObjectFactory}
*/
'private _gameObjFactory': null,
_gameObjFactory: null,
/**
@ -96,7 +96,7 @@ module.exports = Class( 'ClassicGame' )
* @param {string} ltg_data binary string containing LTG file data
* @param {string} lvl_data binary string containing LVL file data
*/
__construct: function( document, ltg_data, lvl_data )
__construct( document, ltg_data, lvl_data )
{
const _self = this;
@ -126,7 +126,7 @@ module.exports = Class( 'ClassicGame' )
*
* @return {ClassicGame} self
*/
'public renderTo': function( ctx, event_target )
renderTo( ctx, event_target )
{
// if there is a previous renderer, free its canvas before
// continuing (to both clean up and to free any locks, allowing for
@ -178,7 +178,7 @@ module.exports = Class( 'ClassicGame' )
*
* @return {ClassicGame} self
*/
'public setTileData': function( data, callback )
setTileData( data, callback )
{
// get tile metadata
const _self = this,
@ -202,7 +202,7 @@ module.exports = Class( 'ClassicGame' )
*
* @return {ClassicGame} self
*/
'public setLevelData': function( data, callback )
setLevelData( data, callback )
{
this._levelSet = LevelSet( data, ClassicLevel );
@ -222,7 +222,7 @@ module.exports = Class( 'ClassicGame' )
*
* @return {ClassicGame} self
*/
'public on': function( name, callback )
on( name, callback )
{
this._callback[ name ] = callback;
return this;
@ -236,7 +236,7 @@ module.exports = Class( 'ClassicGame' )
*
* @return {ClassicGame} self
*/
'private _trigger': function( name )
_trigger( name )
{
if ( typeof this._callback[ name ] === 'function' )
{

View File

@ -27,22 +27,22 @@ module.exports = Class( 'ClassicGameObjectFactory' )
.implement( GameObjectFactory )
.extend(
{
'private _objs': {},
_objs: {},
__construct: function()
__construct()
{
this._initObjs();
},
'public createObject': function( id )
createObject( id )
{
return ( this._objs[ id ] || GameObject )( id );
},
'private _initObjs': function()
_initObjs()
{
this._objs = {
dirt: null,

View File

@ -43,7 +43,7 @@ module.exports = Class( 'ClassicTileDfn' )
*
* @return {Array.<Array.<string,number>>} tile definition
*/
'public getTileDefinition': function()
getTileDefinition()
{
return [
[ 'dirt', 0 ], /* dirt */
@ -121,7 +121,7 @@ module.exports = Class( 'ClassicTileDfn' )
*
* @return {Array.<number>} tile width, tile height, tiles per row
*/
'public getTileDimensions': function()
getTileDimensions()
{
return [ 32, 32, 10 ];
}

View File

@ -36,13 +36,13 @@ module.exports = Class( 'FileLoader',
* DOM file element to watch
* @type {HTMLInputElement}
*/
'private _element': null,
_element: null,
/**
* Callback to call on file load
* @type {function(Error,string)}
*/
'private _callback': null,
_callback: null,
/**
@ -51,7 +51,7 @@ module.exports = Class( 'FileLoader',
* @param {HtmlInputElement} element file element to monitor
* @param {FileReader} reader file reader
*/
__construct: function( element, reader )
__construct( element, reader )
{
if ( element.type !== 'file' )
{
@ -75,7 +75,7 @@ module.exports = Class( 'FileLoader',
*
* @return {FileLoader} self
*/
'public onLoad': function( callback )
onLoad( callback )
{
this._callback = callback;
@ -100,7 +100,7 @@ module.exports = Class( 'FileLoader',
*
* @return {undefined}
*/
'private _loadFile': function( event )
_loadFile( event )
{
const _self = this,
files = event.target.files;

View File

@ -35,7 +35,7 @@ module.exports = Interface( 'Game',
*
* @return {Game} self
*/
'public renderTo': [ 'ctx' ],
renderTo: [ 'ctx' ],
/**
@ -46,7 +46,7 @@ module.exports = Interface( 'Game',
*
* @return {Game} self
*/
'public setTileData': [ 'data', 'callback' ],
setTileData: [ 'data', 'callback' ],
/**
@ -57,7 +57,7 @@ module.exports = Interface( 'Game',
*
* @return {Game} self
*/
'public setLevelData': [ 'data', 'callback' ],
setLevelData: [ 'data', 'callback' ],
/**
@ -71,5 +71,5 @@ module.exports = Interface( 'Game',
*
* @return {Game} self
*/
'public on': [ 'name', 'callback' ]
on: [ 'name', 'callback' ]
} );

View File

@ -54,17 +54,17 @@ const Class = require( 'easejs' ).Class;
module.exports = Class( 'LtgLoader',
{
/** various data segment byte offsets and lengths **/
'private const _POS_NAME': [ 0, 40 ],
'private const _POS_AUTHOR': [ 40, 30 ],
'private const _POS_DESC': [ 70, 245 ],
'private const _POS_ID': [ 315, 5 ],
'private const _POS_MOFF': [ 320, 4 ],
'const _POS_NAME': [ 0, 40 ],
'const _POS_AUTHOR': [ 40, 30 ],
'const _POS_DESC': [ 70, 245 ],
'const _POS_ID': [ 315, 5 ],
'const _POS_MOFF': [ 320, 4 ],
/**
* Beginning of game bitmap (one byte past the header)
* @type {number}
*/
'private const _OFFSET_HEADER_END': 324,
'const _OFFSET_HEADER_END': 324,
/**
@ -74,7 +74,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {Object} LTG metadata and bitmaps (sans mask offset)
*/
'public fromString': function( ltg_data )
fromString( ltg_data )
{
const mask_offset = this._getMaskOffsetFromData( ltg_data );
@ -105,7 +105,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} requested segment
*/
'private _getDataSegment': function( ltg_data, sgmt, stripnull )
_getDataSegment( ltg_data, sgmt, stripnull )
{
// strip null bytes by default
stripnull = ( stripnull === undefined ) ? true : !!stripnull;
@ -130,7 +130,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} LTG name, null bytes stripped
*/
'private _getNameFromData': function( ltg_data )
_getNameFromData( ltg_data )
{
return this._getDataSegment( ltg_data, '_POS_NAME' );
},
@ -143,7 +143,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} LTG author, null bytes stripped
*/
'private _getAuthorFromData': function( ltg_data )
_getAuthorFromData( ltg_data )
{
return this._getDataSegment( ltg_data, '_POS_AUTHOR' );
},
@ -156,7 +156,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} LTG description, null bytes stripped
*/
'private _getDescFromData': function( ltg_data )
_getDescFromData( ltg_data )
{
return this._getDataSegment( ltg_data, '_POS_DESC' );
},
@ -169,7 +169,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} LTG id, null bytes stripped
*/
'private _getIdFromData': function( ltg_data )
_getIdFromData( ltg_data )
{
return this._getDataSegment( ltg_data, '_POS_ID' );
},
@ -185,7 +185,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {number} LTG mask offset in bytes
*/
'private _getMaskOffsetFromData': function( ltg_data )
_getMaskOffsetFromData( ltg_data )
{
// grab the data and don't bother stripping off the null bytes (it would
// function the same with them stripped, but let's avoid the confusion
@ -217,7 +217,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} data URL corresponding to the given bitmap data
*/
'private _getBitmapDataUrl': function( data )
_getBitmapDataUrl( data )
{
return 'data:image/bmp;base64,' + btoa( data );
},
@ -236,7 +236,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} game bitmap data
*/
'private _getGameBitmap': function( ltg_data, mask_offset )
_getGameBitmap( ltg_data, mask_offset )
{
const bmp_offset = this.__self.$( '_OFFSET_HEADER_END' );
@ -256,7 +256,7 @@ module.exports = Class( 'LtgLoader',
*
* @return {string} mask bitmap data
*/
'private _getMaskBitmap': function( ltg_data, mask_offset )
_getMaskBitmap( ltg_data, mask_offset )
{
// the mask bitmap accounts for the remainder of the data
return ltg_data.substr( mask_offset );

View File

@ -103,7 +103,7 @@ module.exports = Interface( 'TileDfn',
*
* @return {Array.<Array.<string,number>>} tile definition
*/
'public getTileDefinition': [],
getTileDefinition: [],
/**
@ -115,5 +115,5 @@ module.exports = Interface( 'TileDfn',
*
* @return {Array.<number>} tile width, tile height, tiles per row
*/
'public getTileDimensions': []
getTileDimensions: []
} );

View File

@ -75,49 +75,49 @@ module.exports = Class( 'TileMasker',
* Canvas 2D context (used for masking and tile slicing)
* @type {CanvasRenderingContext2d}
*/
'private _context': null,
_context: null,
/**
* DOM document
* @type {HTMLDocument}
*/
'private _document': null,
_document: null,
/**
* Tile definition to use for all operations
* @type {Array.<Array.<string,number>>}
*/
'private _tileDfn': null,
_tileDfn: null,
/**
* Width of each individual tile
* @type {number}
*/
'private _tileWidth': 0,
_tileWidth: 0,
/**
* Height of each individual tile
* @type {number}
*/
'private _tileHeight': 0,
_tileHeight: 0,
/**
* Number of tiles per row
* @type {number}
*/
'private _tilesPerRow': 0,
_tilesPerRow: 0,
/**
* Calculated width of tile set provided a tile definition
* @type {number}
*/
'private _setWidth': 0,
_setWidth: 0,
/**
* Calculated height of tile set provided a tile definition
* @type {number}
*/
'private _setHeight': 0,
_setHeight: 0,
/**
@ -133,7 +133,7 @@ module.exports = Class( 'TileMasker',
* @param {TileDfn} tile_dfn tile definition object
* @param {HTMLDocument} document DOM document
*/
__construct: function( tile_dfn, document )
__construct( tile_dfn, document )
{
if ( !( Class.isA( TileDfn, tile_dfn ) ) )
{
@ -169,7 +169,7 @@ module.exports = Class( 'TileMasker',
*
* @return {undefined}
*/
'private _calcSetDimensions': function( tile_dfn )
_calcSetDimensions( tile_dfn )
{
// these vars are for clarity
const sizes = tile_dfn.getTileDimensions(),
@ -210,7 +210,7 @@ module.exports = Class( 'TileMasker',
*
* @return {TileMasker} self
*/
'public getMaskedTiles': function( bmp_game, bmp_mask, callback )
getMaskedTiles( bmp_game, bmp_mask, callback )
{
const _self = this;
@ -235,7 +235,7 @@ module.exports = Class( 'TileMasker',
*
* @return {Array.<number>} tile width, height and number per row
*/
'protected getTileDimensions': function()
'protected getTileDimensions'()
{
return [ this._tileWidth, this._tileHeight, this._tilesPerRow ];
},
@ -257,7 +257,7 @@ module.exports = Class( 'TileMasker',
*
* @return {undefined}
*/
'virtual protected getMaskedTileSet': function( data_mask, callback )
'virtual protected getMaskedTileSet'( data_mask, callback )
{
const tdata = this._tileDfn,
len = tdata.length,
@ -307,7 +307,7 @@ module.exports = Class( 'TileMasker',
*
* @return {undefined}
*/
'protected appendTileFrame': function( set, id, mask, data )
'protected appendTileFrame'( set, id, mask, data )
{
const prev = set[ id ];
@ -357,7 +357,7 @@ module.exports = Class( 'TileMasker',
*
* @return {Object} image data for the requested tile
*/
'virtual protected getMaskedTileData': function( data_mask, x, y )
'virtual protected getMaskedTileData'( data_mask, x, y )
{
const raw = this.getTileData( x, y ),
w = raw.width,
@ -404,7 +404,7 @@ module.exports = Class( 'TileMasker',
*
* @return {Object} image data for tile
**/
'protected getTileData': function( x, y )
'protected getTileData'( x, y )
{
return this._context.getImageData(
x, y, this._tileWidth, this._tileHeight
@ -425,7 +425,7 @@ module.exports = Class( 'TileMasker',
*
* @return {undefined}
*/
'private _renderImage': function( bmp, callback )
_renderImage( bmp, callback )
{
const _self = this,
img = this._document.createElement( 'img' );
@ -448,7 +448,7 @@ module.exports = Class( 'TileMasker',
*
* @return {undefined}
*/
'private _getImageData': function( bmp, callback )
_getImageData( bmp, callback )
{
const _self = this;

View File

@ -25,27 +25,27 @@ module.exports = Class( 'GameObject',
'private _tid': '',
__construct: function( tid )
__construct( tid )
{
this._tid = ''+tid;
this._pos = 0;
},
'public getTid': function()
getTid()
{
return this._tid;
},
'public cloneTo': function( dest )
cloneTo( dest )
{
return dest;
},
/* jshint -W098 */
'virtual public move': function( dir, c, sc )
'virtual move'( dir, c, sc )
{
// move in the appropriate direction (action has been pre-configured
// with the correct direction)

View File

@ -24,7 +24,7 @@ const Class = require( 'easejs' ).Class,
module.exports = Class( 'Tank' )
.extend( GameObject,
{
'override public move': function( direction, c, sc )
'override move'( direction, c, sc )
{
const state = [ 'tleft', 'tup', 'tright', 'tdown' ][ direction ];

View File

@ -57,7 +57,7 @@ module.exports = Class( 'ClassicLevel' )
* Size of each level in bytes
* @type {number}
*/
'private const _SIZE': 576,
'const _SIZE': 576,
/**
* Game object offset and size
@ -67,25 +67,25 @@ module.exports = Class( 'ClassicLevel' )
*
* @type {Array.<number>}
*/
'private const _GOSIZE': [ 0, 256 ],
'const _GOSIZE': [ 0, 256 ],
/**
* Offset and length of level name
* @type {Array.<number>}
*/
'private const _NAMESIZE': [ 256, 31 ],
'const _NAMESIZE': [ 256, 31 ],
/**
* Offset and length of level hint
* @type {Array.<number>}
*/
'private const _HINTSIZE': [ 287, 256 ],
'const _HINTSIZE': [ 287, 256 ],
/**
* Offset and length of author name
* @type {Array.<number>}
*/
'private const _AUTHORSIZE': [ 543, 31 ],
'const _AUTHORSIZE': [ 543, 31 ],
/**
* Offset and length of difficulty level
@ -94,13 +94,13 @@ module.exports = Class( 'ClassicLevel' )
*
* @type {Array.<number>}
*/
'private const _DIFFSIZE': [ 574, 2 ],
'const _DIFFSIZE': [ 574, 2 ],
/**
* Tunnel bitmask
* @type {number}
*/
'private const _TMASK': 0x40,
'const _TMASK': 0x40,
/**
* Colors used to identify tunnels
@ -115,7 +115,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @type {Array.<string>}
*/
'private const _TCOLORS': [
'const _TCOLORS': [
'#ff0000', '#00ff00', '#0000ff', '#00ffff', // r g b c
'#ffff00', '#ff00ff', '#ffffff', '#808080' // y m w b
],
@ -125,19 +125,19 @@ module.exports = Class( 'ClassicLevel' )
* Level set data (binary string)
* @type {string}
*/
'private _data': null,
_data: null,
/**
* Level id (1-indexed)
* @type {string}
*/
'private _id': 0,
_id: 0,
/**
* Offset of beginning of level data in bytes
* @type {number}
*/
'private _offset': 0,
_offset: 0,
/**
@ -146,7 +146,7 @@ module.exports = Class( 'ClassicLevel' )
* @param {LevelSet} set level set data
* @param {number} id 1-indexed level id
*/
__construct: function( data, id )
__construct( data, id )
{
this._data = ''+( data );
this._id = +id;
@ -169,7 +169,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {Array.<number>} array of game objects
*/
'public getObjects': function()
getObjects()
{
const tiles = this._getDataSegment( '_GOSIZE', false ).split( '' );
let i = tiles.length;
@ -189,7 +189,7 @@ module.exports = Class( 'ClassicLevel' )
* @param {string} name name of constant containing segment dfn
* @param {=boolean} stripnull whether to strip null bytes (default true)
*/
'private _getDataSegment': function( name, stripnull )
_getDataSegment( name, stripnull )
{
stripnull = ( arguments.length < 2 ) ? true : !!stripnull;
@ -207,7 +207,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {Array.<number>} width and height in tiles
*/
'public getDimensions': function()
getDimensions()
{
return [ 16, 16 ];
},
@ -218,7 +218,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {Array.<string>}
*/
'public getObjectTileLevel': function()
getObjectTileLevel()
{
// we return these values here instead of returning, say, a constant,
// because we would have to clone it to ensure that our inner state
@ -245,7 +245,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {string} tunnel color
*/
'public getTunnelColor': function( oid )
getTunnelColor( oid )
{
// get the tunnel id by stripping off the tunnel bitmask and then
// grab the associated color
@ -260,7 +260,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {boolean} true if tunnel, otherwise false
*/
'public isObjectTunnel': function( oid )
isObjectTunnel( oid )
{
return ( oid & this.__self.$( '_TMASK' ) );
},
@ -271,7 +271,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {string} level name
*/
'public getLevelName': function()
getLevelName()
{
return this._getDataSegment( '_NAMESIZE' );
},
@ -282,7 +282,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {string} level author name
*/
'public getLevelAuthor': function()
getLevelAuthor()
{
return this._getDataSegment( '_AUTHORSIZE' );
},
@ -293,7 +293,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {string} level hint
*/
'public getLevelHint': function()
getLevelHint()
{
return this._getDataSegment( '_HINTSIZE' );
},
@ -311,7 +311,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {number} 0-indexed difficulty level
*/
'public getLevelDifficulty': function()
getLevelDifficulty()
{
const val = this._getDataSegment( '_DIFFSIZE', false );
@ -341,7 +341,7 @@ module.exports = Class( 'ClassicLevel' )
*
* @return {number} size of level in bytes
*/
'public static getLevelSize': function()
'static getLevelSize'()
{
return this.$( '_SIZE' );
}

View File

@ -63,7 +63,7 @@ module.exports = Interface( 'Level',
*
* @return {Array.<number>} array of game objects
*/
'public getObjects': [],
getObjects: [],
/**
@ -71,7 +71,7 @@ module.exports = Interface( 'Level',
*
* @return {Array.<number>} width and height in tiles
*/
'public getDimensions': [],
getDimensions: [],
/**
@ -79,7 +79,7 @@ module.exports = Interface( 'Level',
*
* @return {Array.<string>}
*/
'public getObjectTileLevel': [],
getObjectTileLevel: [],
/**
@ -94,7 +94,7 @@ module.exports = Interface( 'Level',
*
* @return {string} tunnel color or reasonable default if invalid obj id
*/
'public getTunnelColor': [ 'object_id' ],
getTunnelColor: [ 'object_id' ],
/**
@ -102,7 +102,7 @@ module.exports = Interface( 'Level',
*
* @return {boolean} true if tunnel, otherwise false
*/
'public isObjectTunnel': [ 'object_id' ],
isObjectTunnel: [ 'object_id' ],
/**
@ -110,7 +110,7 @@ module.exports = Interface( 'Level',
*
* @return {string} level name
*/
'public getLevelName': [],
getLevelName: [],
/**
@ -118,7 +118,7 @@ module.exports = Interface( 'Level',
*
* @return {string} level author name
*/
'public getLevelAuthor': [],
getLevelAuthor: [],
/**
@ -126,7 +126,7 @@ module.exports = Interface( 'Level',
*
* @return {string} level hint
*/
'public getLevelHint': [],
getLevelHint: [],
/**
@ -137,7 +137,7 @@ module.exports = Interface( 'Level',
*
* @return {number} 0-indexed difficulty level
*/
'public getLevelDifficulty': [],
getLevelDifficulty: [],
/**
@ -145,5 +145,5 @@ module.exports = Interface( 'Level',
*
* @return {number} size of level in bytes
*/
'public static getLevelSize': []
'static getLevelSize': []
} );

View File

@ -32,16 +32,16 @@ module.exports = Class( 'LevelAction',
'const D__MAX': 3,
'private _dir': 0,
'private _srcPos': 0,
'public srcPos': 0,
_dir: 0,
_srcPos: 0,
srcPos: 0,
'private _bounds': null,
_bounds: null,
'private _moveCallback': null,
_moveCallback: null,
__construct: function( bounds, move_callback )
__construct( bounds, move_callback )
{
if ( !( Class.isA( LevelBounds, bounds ) ) )
{
@ -55,7 +55,7 @@ module.exports = Class( 'LevelAction',
},
'public move': function()
move()
{
const method = [
'getLeftPos',

View File

@ -33,13 +33,13 @@ module.exports = Class( 'LevelBounds',
* Level width (number of tiles)
* @type {number}
*/
'private _mw': 0,
_mw: 0,
/**
* Level height (number of tiles)
* @type {number}
*/
'private _mh': 0,
_mh: 0,
/**
@ -47,7 +47,7 @@ module.exports = Class( 'LevelBounds',
*
* @param {Level} level level for which bounds should be calculated
*/
__construct: function( level )
__construct( level )
{
if ( !( Class.isA( Level, level ) ) )
{
@ -72,7 +72,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {number} tile position above given position or current position
*/
'public getUpperPos': function( pos )
getUpperPos( pos )
{
return ( this.isAtTop( pos ) )
? pos
@ -90,7 +90,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {number} tile position below given position or current position
*/
'public getLowerPos': function( pos )
getLowerPos( pos )
{
return ( this.isAtBottom( pos ) )
? pos
@ -109,7 +109,7 @@ module.exports = Class( 'LevelBounds',
* @return {number} tile position left of given position or current
* position
*/
'public getLeftPos': function( pos )
getLeftPos( pos )
{
return ( this.isAtLeft( pos ) )
? pos
@ -128,7 +128,7 @@ module.exports = Class( 'LevelBounds',
* @return {number} tile position right of given position or current
* position
*/
'public getRightPos': function( pos )
getRightPos( pos )
{
return ( this.isAtRight( pos ) )
? pos
@ -143,7 +143,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {boolean} true if within topmost row, otherwise false
*/
'public isAtTop': function( pos )
isAtTop( pos )
{
// since tile positions are zero-indexed, we know that we're at the
// top if the level height divides the position
@ -158,7 +158,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {boolean} true if within bottom row, otherwise false
*/
'public isAtBottom': function( pos )
isAtBottom( pos )
{
// this "works" because tile positions are vertically indexed
return this.isAtTop( pos + 1 );
@ -173,7 +173,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {boolean} true if within leftmost column, otherwise false
*/
'public isAtLeft': function( pos )
isAtLeft( pos )
{
// check if index is within the left-most column
return ( pos <= this._mh );
@ -188,7 +188,7 @@ module.exports = Class( 'LevelBounds',
*
* @return {boolean} true if within rightmost column, otherwise false
*/
'public isAtRight': function( pos )
isAtRight( pos )
{
// check if index is within the right-most column
return ( pos >= ( this._mh * ( this._mw - 1 ) ) );

View File

@ -30,38 +30,38 @@ module.exports = Class( 'LevelRender',
* Property to hold lock bit on canvas element
* @type {string}
*/
'private const _LOCK': '__$$LevelRenderLock$$',
'const _LOCK': '__$$LevelRenderLock$$',
/**
* Animation interval in milliseconds
* @type {number}
*/
'private const _ANIM_INTERVAL': 200,
'const _ANIM_INTERVAL': 200,
/**
* 2d context to which level should be drawn
* @type {CanvasRenderingContext2d}
*/
'private _ctx': null,
_ctx: null,
/**
* 2d context to which masked game objects should be drawn
* @type {CanvasRenderingContext2d}
*/
'private _ctxObj': null,
_ctxObj: null,
/**
* Tile set to be rendered
* @type {Object}
*/
'private _tiles': {},
_tiles: {},
/**
* Animation timer
* @type {number}
*/
'private _animTimer': 0,
_animTimer: 0,
/**
@ -73,7 +73,7 @@ module.exports = Class( 'LevelRender',
* @param {CanvasRenderingContext2d} ctx canvas 2d context
* @param {Object} tiles tile set to render
*/
__construct: function( ctx, tiles )
__construct( ctx, tiles )
{
this._ctx = ctx;
this._tiles = tiles;
@ -97,7 +97,7 @@ module.exports = Class( 'LevelRender',
*
* @return {undefined}
*/
'private _lockCanvas': function()
_lockCanvas()
{
const o = this._ctx,
l = this.__self.$( '_LOCK' );
@ -127,7 +127,7 @@ module.exports = Class( 'LevelRender',
*
* @return {LevelRender} self
*/
'public freeCanvas': function()
freeCanvas()
{
const c = this._ctxObj.canvas;
@ -148,7 +148,7 @@ module.exports = Class( 'LevelRender',
*
* @return {CanvasRenderingContext2d} 2d context for new canvas element
*/
'private _getObjCanvas': function()
_getObjCanvas()
{
const canvas = this._ctx.canvas,
document = this._getDocument( canvas ),
@ -179,7 +179,7 @@ module.exports = Class( 'LevelRender',
*
* @return {HTMLDocument} document node
*/
'private _getDocument': function( element )
_getDocument( element )
{
return ( element.parentElement === null )
? element.parentNode
@ -194,7 +194,7 @@ module.exports = Class( 'LevelRender',
*
* @return {LevelRender} self
*/
'public render': function( level, level_state )
render( level, level_state )
{
if ( !( Class.isA( LevelState, level_state ) ) )
{
@ -272,7 +272,7 @@ module.exports = Class( 'LevelRender',
*
* @return {Array.<number>} x and y coordinates of tile position
*/
'private _getTileVector': function( pos, sizex, sizey, w, h )
_getTileVector( pos, sizex, sizey, w, h )
{
return [
( Math.floor( pos / sizex ) * w ), // x
@ -298,7 +298,7 @@ module.exports = Class( 'LevelRender',
*
* @return {undefined}
*/
'private _clearCanvases': function()
_clearCanvases()
{
const ctx = this._ctxObj,
c = ctx.canvas;
@ -316,7 +316,7 @@ module.exports = Class( 'LevelRender',
*
* @return {boolean} true if multiple frames, otherwise false
*/
'private _canAnimate': function( tid )
_canAnimate( tid )
{
const tdata = this._tiles[ tid ];
return ( tdata.next !== tdata );
@ -337,7 +337,7 @@ module.exports = Class( 'LevelRender',
*
* @return {undefined}
*/
'private _drawTile': function( tile, x, y )
_drawTile( tile, x, y )
{
const ctx = ( tile.masked ) ? this._ctxObj : this._ctx;
@ -350,7 +350,7 @@ module.exports = Class( 'LevelRender',
},
'private _clearTile': function( ref, x, y )
_clearTile( ref, x, y )
{
this._ctxObj.clearRect( x, y, ref.data.width, ref.data.height );
},
@ -369,7 +369,7 @@ module.exports = Class( 'LevelRender',
*
* @return {undefined}
*/
'private _renderTunnel': function( x, y, color )
_renderTunnel( x, y, color )
{
const tdata = this._tiles.tunnel.data;
@ -393,7 +393,7 @@ module.exports = Class( 'LevelRender',
*
* @return {number} animation timer id
*/
'private _beginAnimation': function( anim )
_beginAnimation( anim )
{
const _self = this;
@ -424,7 +424,7 @@ module.exports = Class( 'LevelRender',
*
* @return {undefined}
*/
'private _clearAnimation': function()
_clearAnimation()
{
this._animTimer = +clearInterval( this._animTimer );
}

View File

@ -36,19 +36,19 @@ module.exports = Class( 'LevelSet',
* Raw level set data (binary)
* @type {string}
*/
'private _data': '',
_data: '',
/**
* Constructor used to create new level instances
* @type {Function}
*/
'private _levelCtor': null,
_levelCtor: null,
/**
* Number of levels in the given LVL data
* @type {number}
*/
'private _levelCount': 0,
_levelCount: 0,
/**
@ -59,7 +59,7 @@ module.exports = Class( 'LevelSet',
* @param {string} data binary LVL data
* @param {Level} level_ctor Level constructor
*/
__construct: function( data, level_ctor )
__construct( data, level_ctor )
{
this._data = ''+( data );
this._levelCtor = level_ctor;
@ -82,7 +82,7 @@ module.exports = Class( 'LevelSet',
*
* @return {undefined}
*/
'private _levelDataCheck': function()
_levelDataCheck()
{
const n = ( this._data.length / this._levelCtor.getLevelSize() );
@ -103,7 +103,7 @@ module.exports = Class( 'LevelSet',
*
* @param {number} id number of level to load, 1-indexed
*/
'public getLevelByNumber': function( id )
getLevelByNumber( id )
{
return this._levelCtor( this._data, id );
},
@ -114,7 +114,7 @@ module.exports = Class( 'LevelSet',
*
* @return {number} number of levels
*/
'public getLevelCount': function()
getLevelCount()
{
return this._levelCount;
},

View File

@ -32,31 +32,31 @@ module.exports = Class( 'LevelState',
* Game object factory
* @type {GameObjectFactory}
*/
'private _objFactory': null,
_objFactory: null,
/**
* Player game object tile position
* @type {number}
*/
'private _playerPos': 0,
_playerPos: 0,
/**
* Reference to player object
* @type {GameObject}
*/
'private _player': null,
_player: null,
/**
* Game objects representing every object on the level
* @type {GameObject}
*/
'private _objs': [],
_objs: [],
/**
* Continuations to invoke when object state changes
* @type {Array.<function(GameObject,number)>}
*/
'private _stateCallbacks': [],
_stateCallbacks: [],
/**
@ -70,7 +70,7 @@ module.exports = Class( 'LevelState',
* @param {Level} level game level
* @param {GameObjectFactory} obj_factory game object factory
*/
__construct: function( level, obj_factory )
__construct( level, obj_factory )
{
if ( !( Class.isA( GameObjectFactory, obj_factory ) ) )
{
@ -92,7 +92,7 @@ module.exports = Class( 'LevelState',
* performant (especially since the level size could be arbitrarily
* large).
*/
'public flush': function()
flush()
{
const _self = this;
@ -122,7 +122,7 @@ module.exports = Class( 'LevelState',
*
* @return {LevelState} self
*/
'public onChange': function( callback )
onChange( callback )
{
this._stateCallbacks.push( callback );
return this;
@ -143,7 +143,7 @@ module.exports = Class( 'LevelState',
*
* @return {undefined}
*/
'private _emitChange': function( obj, pos )
_emitChange( obj, pos )
{
const l = this._stateCallbacks.length;
let i = -1;
@ -178,7 +178,7 @@ module.exports = Class( 'LevelState',
*
* @return {undefined}
*/
'private _initObjects': function( objs, objlevel )
_initObjects( objs, objlevel )
{
let i = objs.length;
@ -214,7 +214,7 @@ module.exports = Class( 'LevelState',
*
* @return {GameObject} new game object
*/
'private _createObj': function( tid, from )
_createObj( tid, from )
{
const obj = this._objFactory.createObject( tid );
@ -239,7 +239,7 @@ module.exports = Class( 'LevelState',
*
* @return {undefined}
*/
'private _forEachObj': function( c )
_forEachObj( c )
{
this._objs.forEach( function( objs, pos )
{
@ -265,7 +265,7 @@ module.exports = Class( 'LevelState',
* @throws {Error} if an invalid tile position
* @throws {TypeError} if an invalid replacement game object
*/
'private _addObj': function( obj, pos )
_addObj( obj, pos )
{
// replace no object with the given object (that is, replace nothing
// with something---add)
@ -303,7 +303,7 @@ module.exports = Class( 'LevelState',
* @throws {Error} if an invalid tile position
* @throws {TypeError} if an invalid replacement game object
*/
'private _replaceObj': function( cur, newobj, pos )
_replaceObj( cur, newobj, pos )
{
const o = this._objs[ pos ];
@ -361,7 +361,7 @@ module.exports = Class( 'LevelState',
*
* @throws {Error} if an invalid tile position
*/
'private _removeObj': function( obj, pos )
_removeObj( obj, pos )
{
this._replaceObj( obj, null, pos );
},
@ -385,7 +385,7 @@ module.exports = Class( 'LevelState',
* @throws {TypeError} if an invalid game object
* @throws {Error} if an invalid tile position
*/
'private _moveObj': function( obj, from, to )
_moveObj( obj, from, to )
{
this._removeObj( obj, from );
this._addObj( obj, to );
@ -402,7 +402,7 @@ module.exports = Class( 'LevelState',
* @param {GameObject} obj game object representing the player
* @param {number} pos player tile position
*/
'private _initPlayer': function( obj, pos )
_initPlayer( obj, pos )
{
this._player = obj;
this._playerPos = pos;
@ -428,7 +428,7 @@ module.exports = Class( 'LevelState',
* @throws {TypeError} if state results in an invalid game object
* @throws {Error} if an invalid tile position
*/
'private _changeState': function( cur, state, pos )
_changeState( cur, state, pos )
{
// if the state has not changed, then do nothing
if ( state === cur.getTid() )
@ -461,7 +461,7 @@ module.exports = Class( 'LevelState',
*
* @return {function(string)} callback to perform state change
*/
'private _createStateCallback': function( cur, pos, c )
_createStateCallback( cur, pos, c )
{
const _self = this;
@ -494,7 +494,7 @@ module.exports = Class( 'LevelState',
*
* @return {function(string)} callback to perform state change
*/
'private _createMoveCallback': function( obj, pos, c )
_createMoveCallback( obj, pos, c )
{
const _self = this;
@ -524,7 +524,7 @@ module.exports = Class( 'LevelState',
*
* @return {undefined}
*/
'public movePlayer': function( direction, bounds )
movePlayer( direction, bounds )
{
const _self = this,
player = this._player;

View File

@ -32,7 +32,7 @@ module.exports = Class( 'MenuBar',
* DOM element representing the menu bar
* @type {Element}
*/
'private _bar': null,
_bar: null,
/**
@ -44,7 +44,7 @@ module.exports = Class( 'MenuBar',
*
* @param {Element} element DOM element representing menu bar
*/
__construct: function( element )
__construct( element )
{
// we'll need an id set for this element
if ( !element.id )
@ -66,7 +66,7 @@ module.exports = Class( 'MenuBar',
*
* @return {undefined}
*/
'private _initMenuActivation': function()
_initMenuActivation()
{
const id = this._bar.id,
menus = this._bar.parentNode.querySelectorAll( '#'+id+' > li > a' ),
@ -100,7 +100,7 @@ module.exports = Class( 'MenuBar',
*
* @return {undefined}
*/
'private _hookMenuMouseOut': function()
_hookMenuMouseOut()
{
const _self = this,
bar = this._bar;
@ -126,7 +126,7 @@ module.exports = Class( 'MenuBar',
*
* @return {boolean} TRUE if child or node itself, otherwise FALSE
*/
'private _isNodeOrChildOf': function( parent, node )
_isNodeOrChildOf( parent, node )
{
if ( !node || !node.parentNode ) return false;