Decouple TileMasker from window.document
parent
3b1ac2c78c
commit
93b61596b3
|
@ -66,7 +66,7 @@ function gamechk()
|
||||||
// temporary
|
// temporary
|
||||||
if ( ele_game.className.search( 'opening' ) > -1 ) return;
|
if ( ele_game.className.search( 'opening' ) > -1 ) return;
|
||||||
|
|
||||||
lasertank.ClassicGame( ltg_data, lvl_data )
|
lasertank.ClassicGame( document, ltg_data, lvl_data )
|
||||||
.on( 'ready', function()
|
.on( 'ready', function()
|
||||||
{
|
{
|
||||||
this.renderTo( ctx, window );
|
this.renderTo( ctx, window );
|
||||||
|
|
|
@ -88,15 +88,20 @@ module.exports = Class( 'ClassicGame' )
|
||||||
* the constructor because they are needed in order for the game to be
|
* the constructor because they are needed in order for the game to be
|
||||||
* functional.
|
* functional.
|
||||||
*
|
*
|
||||||
|
* DOCUMENT is used internally for creating elements; the DOM will not
|
||||||
|
* be manipulated.
|
||||||
|
*
|
||||||
|
* @param {HTMLDocument} document DOM document
|
||||||
|
*
|
||||||
* @param {string} ltg_data binary string containing LTG file data
|
* @param {string} ltg_data binary string containing LTG file data
|
||||||
* @param {string} lvl_data binary string containing LVL file data
|
* @param {string} lvl_data binary string containing LVL file data
|
||||||
*/
|
*/
|
||||||
__construct: function( ltg_data, lvl_data )
|
__construct: function( document, ltg_data, lvl_data )
|
||||||
{
|
{
|
||||||
const _self = this;
|
const _self = this;
|
||||||
|
|
||||||
this._ltgLoader = LtgLoader();
|
this._ltgLoader = LtgLoader();
|
||||||
this._masker = TileMasker( ClassicTileDfn() );
|
this._masker = TileMasker( ClassicTileDfn(), document );
|
||||||
|
|
||||||
this._gameObjFactory = ClassicGameObjectFactory();
|
this._gameObjFactory = ClassicGameObjectFactory();
|
||||||
|
|
||||||
|
|
|
@ -121,9 +121,13 @@ module.exports = Class( 'TileMasker',
|
||||||
* allows us to support *any* type of tile set -- not just those that are
|
* allows us to support *any* type of tile set -- not just those that are
|
||||||
* defined by the original game.
|
* defined by the original game.
|
||||||
*
|
*
|
||||||
* @param {TileDfn} tile_dfn tile definition object
|
* DOCUMENT is used internally for creating elements; the DOM will not
|
||||||
|
* be manipulated.
|
||||||
|
*
|
||||||
|
* @param {TileDfn} tile_dfn tile definition object
|
||||||
|
* @param {HTMLDocument} document DOM document
|
||||||
*/
|
*/
|
||||||
__construct: function( tile_dfn )
|
__construct: function( tile_dfn, document )
|
||||||
{
|
{
|
||||||
if ( !( Class.isA( TileDfn, tile_dfn ) ) )
|
if ( !( Class.isA( TileDfn, tile_dfn ) ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,8 +104,11 @@
|
||||||
reader.onload = function( event )
|
reader.onload = function( event )
|
||||||
{
|
{
|
||||||
var loader = lasertank.LtgLoader(),
|
var loader = lasertank.LtgLoader(),
|
||||||
masker = lasertank.TileMasker( lasertank.ClassicTileDfn() ),
|
|
||||||
meta = loader.fromString( event.target.result ),
|
meta = loader.fromString( event.target.result ),
|
||||||
|
masker = lasertank.TileMasker(
|
||||||
|
lasertank.ClassicTileDfn(),
|
||||||
|
document
|
||||||
|
),
|
||||||
|
|
||||||
bmp_game = document.getElementById( 'bmp_game' ),
|
bmp_game = document.getElementById( 'bmp_game' ),
|
||||||
bmp_mask = document.getElementById( 'bmp_mas' );
|
bmp_mask = document.getElementById( 'bmp_mas' );
|
||||||
|
|
Loading…
Reference in New Issue