138 lines
5.0 KiB
JavaScript
138 lines
5.0 KiB
JavaScript
/**
|
|
* Contains tile definition interface
|
|
*
|
|
* Copyright (C) 2012 Mike Gerwitz
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*
|
|
* This interface provides a definition for the processing of tile sets.
|
|
* Specifically, it includes the width and height of each individual tile, the
|
|
* number of tiles per row, the ids to map each tile to and a flag indicating
|
|
* whether or not the tile should have a mask applied to it.
|
|
*
|
|
* The true benefit of this interface is that it abstracts the tile
|
|
* interpretation logic in such a way that *any* tile set is supported. That is,
|
|
* should someone decide to support entirely separate tile sets (perhaps to
|
|
* add additional features to the game, or even to simply restructure the tile
|
|
* positions of the current one), we have them covered.
|
|
*
|
|
* Below is a list of standard ids that must be mapped for classic game play.
|
|
* The *alt tiles are used in animation (the terminology comes from the original
|
|
* game sources).
|
|
*
|
|
* dirt - dirt
|
|
* tup - tank up
|
|
* tright - tank right
|
|
* tdown - tank down
|
|
* tleft - tank left
|
|
* base - base
|
|
* basealt - base alt
|
|
* basealt2 - base alt 2
|
|
* water - water
|
|
* wateralt - water alt
|
|
*
|
|
* wateralt2 - water alt 2
|
|
* atdownb - anti-tank down
|
|
* block - block
|
|
* mblock - movable block
|
|
* brick - brick
|
|
* atup - anti-tank up
|
|
* atupalt - anti-tank up alt
|
|
* atupalt2 - anti-tank up alt 2
|
|
* mblockw - movable block in water
|
|
* mirrorul - mirror up-left
|
|
*
|
|
* mirrorur - mirror up-right
|
|
* mirrordr - mirror down-right
|
|
* mirrordl - mirror down-left
|
|
* owup - one-way up
|
|
* owupalt - one-way up alt
|
|
* owupalt2 - one-way up alt 2
|
|
* owright - one-way right
|
|
* owrightalt - one-way right alt
|
|
* owrightalt2 - one-way right alt 2
|
|
* owdown - one-way down
|
|
*
|
|
* owdownalt - one-way down alt
|
|
* owdownalt2 - one-way down alt 2
|
|
* owleft - one-way left
|
|
* owleftalt - one-way left alt
|
|
* owleftalt2 - one-way left alt 3
|
|
* atright - anti-tank right
|
|
* atrightalt - anti-tank right alt
|
|
* atrightalt2 - anti-tank right alt 2
|
|
* atdown - anti-tank down
|
|
* atdownalt - anti-tank down alt
|
|
*
|
|
* atdownalt2 - anti-tank down alt 2
|
|
* atleft - anti-tank left
|
|
* atleftalt - anti-tank left alt
|
|
* atleftalt2 - anti-tank left alt 2
|
|
* cblock - crystal block
|
|
* cblockht - crystal block hit by tank
|
|
* rmirrorul - roto-mirror up-left
|
|
* rmirrorur - roto-mirror up-right
|
|
* rmirrordr - roto-mirror down-right
|
|
* rmirrordl - roto-mirror down-left
|
|
*
|
|
* cblockhat - crystal block hit by anti-tank
|
|
* atrightb - anti-tank, blown up, right
|
|
* atleftb - anti-tank, blown up, left
|
|
* atupb - anti-tank, blown up, up
|
|
* tunnel - wormhole/tunnel
|
|
* ice - ice
|
|
* thinice - thin ice
|
|
*/
|
|
|
|
|
|
/**
|
|
* Defines the contents of a tile set
|
|
*
|
|
* The tile set is expected to be an image of any width (W) and height (H)
|
|
* containing individual tiles (of width w and height h) such that W % w === 0
|
|
* and H % h === 0. All tiles are expected to share the same dimensions.
|
|
*/
|
|
ltjs.TileDfn = Interface( 'TileDfn',
|
|
{
|
|
/**
|
|
* Retrieve the tile definition
|
|
*
|
|
* The definition should be an array of arrays, with the first index
|
|
* representing the tile id and the second index representing whether or not
|
|
* a mask should be applied (0 or 1). A list of standard tile ids are
|
|
* provided at the top of this file.
|
|
*
|
|
* The tiles are expected to be parsed per row, beginning at the upper-left
|
|
* corner. Specifying the tiles in this manner is both concise and helps to
|
|
* eliminate human error and maintenance concerns that may arise from the
|
|
* manual specification of tile coordinates.
|
|
*
|
|
* @return {Array.<Array.<string,number>>} tile definition
|
|
*/
|
|
'public getTileDefinition': [],
|
|
|
|
|
|
/**
|
|
* Retrieve tile dimensions
|
|
*
|
|
* This method should return an array containing three values: the width and
|
|
* height of the individual tiles and the number of tiles per row. From this
|
|
* data, any individual tile can be extracted from the tile set.
|
|
*
|
|
* @return {Array.<number>} tile width, tile height, tiles per row
|
|
*/
|
|
'public getTileDimensions': []
|
|
} );
|