Skip to content

Commit

Permalink
Moved the TileMaps into the Graphics namespace.
Browse files Browse the repository at this point in the history
- TileMaps and SquareTileMaps are on the base Graphics namespace
- Tile details and SquareTile's are part of the Graphics.Assets

#66
  • Loading branch information
NTaylorMullen committed Oct 15, 2013
1 parent 70ad48b commit 289770f
Show file tree
Hide file tree
Showing 29 changed files with 105 additions and 109 deletions.
16 changes: 8 additions & 8 deletions EndGate/EndGate.Core.JS/EndGate.Core.JS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@
<Content Include="Map\Loaders\JSON\TMX\TMXLoader.js">
<DependentUpon>TMXLoader.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="Map\TileMaps\ITileDetails.ts" />
<Content Include="Map\TileMaps\ITileDetails.js">
<TypeScriptCompile Include="Graphics\TileMaps\ITileDetails.ts" />
<Content Include="Graphics\TileMaps\ITileDetails.js">
<DependentUpon>ITileDetails.ts</DependentUpon>
</Content>
<TypeScriptCompile Include="Particles\Emitter.ts" />
Expand Down Expand Up @@ -434,16 +434,16 @@
<Content Include="Loopers\TimedCallback.js">
<DependentUpon>TimedCallback.ts</DependentUpon>
</Content>
<CodeAnalysisDictionary Include="Map\TileMaps\SquareTileMap.ts" />
<TypeScriptCompile Include="Map\TileMaps\SquareTile.ts" />
<Content Include="Map\TileMaps\SquareTile.js">
<CodeAnalysisDictionary Include="Graphics\TileMaps\SquareTileMap.ts" />
<TypeScriptCompile Include="Graphics\TileMaps\SquareTile.ts" />
<Content Include="Graphics\TileMaps\SquareTile.js">
<DependentUpon>SquareTile.ts</DependentUpon>
</Content>
<Content Include="Map\TileMaps\SquareTileMap.js">
<Content Include="Graphics\TileMaps\SquareTileMap.js">
<DependentUpon>SquareTileMap.ts</DependentUpon>
</Content>
<CodeAnalysisDictionary Include="Map\TileMaps\TileMap.ts" />
<Content Include="Map\TileMaps\TileMap.js">
<CodeAnalysisDictionary Include="Graphics\TileMaps\TileMap.ts" />
<Content Include="Graphics\TileMaps\TileMap.js">
<DependentUpon>TileMap.ts</DependentUpon>
</Content>
<CodeAnalysisDictionary Include="MovementControllers\LinearDirections.ts" />
Expand Down
4 changes: 2 additions & 2 deletions EndGate/EndGate.Core.JS/EndGateAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
/// <reference path="Assets/Sizes/Size2d.ts" />
/// <reference path="Assets/Vectors/Vector2d.ts" />
/// <reference path="Assets/Matrixes/Matrix2x2.ts" />
/// <reference path="Map/TileMaps/SquareTileMap.ts" />
/// <reference path="Map/TileMaps/TileMap.ts" />
/// <reference path="Graphics/TileMaps/SquareTileMap.ts" />
/// <reference path="Graphics/TileMaps/TileMap.ts" />
// When this file is compiled into a declaration file it does not include this line,
// therefore in the build.ps1 we have to append this aliasing module.
var eg = EndGate;
4 changes: 2 additions & 2 deletions EndGate/EndGate.Core.JS/EndGateAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
/// <reference path="Assets/Sizes/Size2d.ts" />
/// <reference path="Assets/Vectors/Vector2d.ts" />
/// <reference path="Assets/Matrixes/Matrix2x2.ts" />
/// <reference path="Map/TileMaps/SquareTileMap.ts" />
/// <reference path="Map/TileMaps/TileMap.ts" />
/// <reference path="Graphics/TileMaps/SquareTileMap.ts" />
/// <reference path="Graphics/TileMaps/TileMap.ts" />

// When this file is compiled into a declaration file it does not include this line,
// therefore in the build.ps1 we have to append this aliasing module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="../../Graphics/Sprites/Sprite2d.ts" />
/// <reference path="TileMap.ts" />

declare module EndGate.Map {
declare module EndGate.Graphics.Assets {

/**
* Defines an object that is used to fully describe a loaded tile.
Expand Down
34 changes: 34 additions & 0 deletions EndGate/EndGate.Core.JS/Graphics/TileMaps/SquareTile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var __extends = this.__extends || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
__.prototype = b.prototype;
d.prototype = new __();
};
var EndGate;
(function (EndGate) {
(function (Graphics) {
/// <reference path="../../Graphics/ImageSource.ts" />
/// <reference path="../../Graphics/Sprites/Sprite2d.ts" />
(function (Assets) {
/**
* Defines a SquareTile that is used by the SquareTileMap. Represents one tile within the tile map.
*/
var SquareTile = (function (_super) {
__extends(SquareTile, _super);
/**
* Creates a new instance of the SquareTile object.
* @param image The image that is within the tile.
* @param width The width of the tile.
* @param height The height of the tile.
*/
function SquareTile(image, width, height) {
_super.call(this, 0, 0, image, width, height);
}
return SquareTile;
})(EndGate.Graphics.Sprite2d);
Assets.SquareTile = SquareTile;
})(Graphics.Assets || (Graphics.Assets = {}));
var Assets = Graphics.Assets;
})(EndGate.Graphics || (EndGate.Graphics = {}));
var Graphics = EndGate.Graphics;
})(EndGate || (EndGate = {}));
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="../../Graphics/ImageSource.ts" />
/// <reference path="../../Graphics/Sprites/Sprite2d.ts" />

module EndGate.Map {
module EndGate.Graphics.Assets {

/**
* Defines a SquareTile that is used by the SquareTileMap. Represents one tile within the tile map.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var EndGate;
/// <reference path="ITileDetails.ts" />
/// <reference path="TileMap.ts" />
/// <reference path="SquareTile.ts" />
(function (Map) {
(function (Graphics) {
/**
* Defines a structure that is proficient at creating diverse tile maps based off of a resource image. Best drawn via a SceneryHandler.
*/
Expand Down Expand Up @@ -183,7 +183,7 @@ var EndGate;
var action = function () {
var tile, tileGraphic = _this._Resources[resourceIndex];

tile = new Map.SquareTile(tileGraphic, _this._grid.TileSize.Width, _this._grid.TileSize.Height);
tile = new Graphics.Assets.SquareTile(tileGraphic, _this._grid.TileSize.Width, _this._grid.TileSize.Height);

_this._grid.Fill(row, column, tile);

Expand Down Expand Up @@ -229,8 +229,8 @@ var EndGate;
}, this.RowLoadDelay.Milliseconds);
};
return SquareTileMap;
})(Map.TileMap);
Map.SquareTileMap = SquareTileMap;
})(EndGate.Map || (EndGate.Map = {}));
var Map = EndGate.Map;
})(Graphics.TileMap);
Graphics.SquareTileMap = SquareTileMap;
})(EndGate.Graphics || (EndGate.Graphics = {}));
var Graphics = EndGate.Graphics;
})(EndGate || (EndGate = {}));
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/// <reference path="TileMap.ts" />
/// <reference path="SquareTile.ts" />

module EndGate.Map {
module EndGate.Graphics {

/**
* Defines a structure that is proficient at creating diverse tile maps based off of a resource image. Best drawn via a SceneryHandler.
Expand All @@ -29,7 +29,7 @@ module EndGate.Map {
private _mapCache: HTMLCanvasElement;
private _mapCacheContext: CanvasRenderingContext2D;
private _mappings: number[][];
private _onTileLoad: EventHandler2<ITileDetails, number>;
private _onTileLoad: EventHandler2<Assets.ITileDetails, number>;
private _onLoaded: EventHandler;
private _loaded: boolean;
private _tilesBuilt: number;
Expand Down Expand Up @@ -74,7 +74,7 @@ module EndGate.Map {
this._mappings = mappings;
this._grid = new Graphics.Grid(0, 0, mappings.length, mappings[0].length, tileWidth, tileHeight, drawGridLines);
this._staticMap = staticMap;
this._onTileLoad = new EventHandler2<ITileDetails, number>();
this._onTileLoad = new EventHandler2<Assets.ITileDetails, number>();
this._onLoaded = new EventHandler();
this._loaded = false;
this._tilesBuilt = 0;
Expand Down Expand Up @@ -202,7 +202,7 @@ module EndGate.Map {
this._mapCacheContext.translate(size.HalfWidth, size.HalfHeight);
}

private CacheTile(tile: SquareTile): void {
private CacheTile(tile: Assets.SquareTile): void {
// Draw the tile onto the map cache
tile.Draw(this._mapCacheContext);
}
Expand All @@ -217,12 +217,12 @@ module EndGate.Map {
});
}

private AsyncBuildGridTile(row: number, column: number, resourceIndex: number, onComplete: (tile: SquareTile) => any): void {
private AsyncBuildGridTile(row: number, column: number, resourceIndex: number, onComplete: (tile: Assets.SquareTile) => any): void {
var action = () => {
var tile: SquareTile,
var tile: Assets.SquareTile,
tileGraphic: Graphics.ImageSource = this._Resources[resourceIndex];

tile = new SquareTile(tileGraphic, this._grid.TileSize.Width, this._grid.TileSize.Height);
tile = new Assets.SquareTile(tileGraphic, this._grid.TileSize.Width, this._grid.TileSize.Height);

this._grid.Fill(row, column, tile);

Expand Down Expand Up @@ -256,7 +256,7 @@ module EndGate.Map {
this._tilesBuilt++;

if (mappings[rowIndex][tilesLoaded] >= 0) {
this.AsyncBuildGridTile(rowIndex, tilesLoaded, mappings[rowIndex][tilesLoaded], (tile: SquareTile) => {
this.AsyncBuildGridTile(rowIndex, tilesLoaded, mappings[rowIndex][tilesLoaded], (tile: Assets.SquareTile) => {
next();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var EndGate;
/// <reference path="../../Assets/Vectors/Vector2d.ts" />
/// <reference path="../../Graphics/Graphic2d.ts" />
/// <reference path="../../Graphics/ImageSource.ts" />
(function (Map) {
(function (Graphics) {
/**
* Defines an abstract class TileMap that takes an array of resources to be mapped to tiles.
*/
Expand All @@ -34,7 +34,7 @@ var EndGate;
};
return TileMap;
})(EndGate.Graphics.Graphic2d);
Map.TileMap = TileMap;
})(EndGate.Map || (EndGate.Map = {}));
var Map = EndGate.Map;
Graphics.TileMap = TileMap;
})(EndGate.Graphics || (EndGate.Graphics = {}));
var Graphics = EndGate.Graphics;
})(EndGate || (EndGate = {}));
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/// <reference path="../../Graphics/Graphic2d.ts" />
/// <reference path="../../Graphics/ImageSource.ts" />

module EndGate.Map {
module EndGate.Graphics {

/**
* Defines an abstract class TileMap that takes an array of resources to be mapped to tiles.
Expand Down
4 changes: 2 additions & 2 deletions EndGate/EndGate.Core.JS/Map/Loaders/IHookFunction.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/// <reference path="../TileMaps/ITileDetails.ts" />
/// <reference path="../../Graphics/TileMaps/ITileDetails.ts" />

declare module EndGate.Map.Loaders {

/**
* Defines an IHookFunction that represents a function that can be used to hook into map loading tiles.
*/
export interface IHookFunction {
(details: ITileDetails, propertyValue: string): any;
(details: Graphics.Assets.ITileDetails, propertyValue: string): any;
}

}
4 changes: 2 additions & 2 deletions EndGate/EndGate.Core.JS/Map/Loaders/IMapLoadedResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// <reference path="../TileMaps/TileMap.ts" />
/// <reference path="../../Graphics/TileMaps/TileMap.ts" />

declare module EndGate.Map.Loaders {

Expand All @@ -9,7 +9,7 @@ declare module EndGate.Map.Loaders {
/**
* Gets or sets the layers that will represent the scenery of the game. Each layer should be added to the scenery in order to draw the layers.
*/
Layers: Array<TileMap>;
Layers: Array<Graphics.TileMap>;
}

}
1 change: 0 additions & 1 deletion EndGate/EndGate.Core.JS/Map/Loaders/IMapLoader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/// <reference path="../TileMaps/TileMap.ts" />
/// <reference path="IMapPreloadInfo.ts" />
/// <reference path="IPropertyHooks.ts" />

Expand Down
2 changes: 0 additions & 2 deletions EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ var EndGate;
/// <reference path="../IMapPreloadInfo.ts" />
/// <reference path="../IMapLoadedResult.ts" />
/// <reference path="../IPropertyHooks.ts" />
/// <reference path="../../TileMaps/TileMap.ts" />
/// <reference path="../../TileMaps/SquareTileMap.ts" />
(function (Loaders) {
/**
* Defines a JSON loader that is used to load maps.
Expand Down
2 changes: 0 additions & 2 deletions EndGate/EndGate.Core.JS/Map/Loaders/JSON/JSONLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
/// <reference path="../IMapPreloadInfo.ts" />
/// <reference path="../IMapLoadedResult.ts" />
/// <reference path="../IPropertyHooks.ts" />
/// <reference path="../../TileMaps/TileMap.ts" />
/// <reference path="../../TileMaps/SquareTileMap.ts" />

module EndGate.Map.Loaders {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ var EndGate;
/// <reference path="../../IMapLoadedResult.ts" />
/// <reference path="../../IMapPreloadInfo.ts" />
/// <reference path="../../IHookFunction.ts" />
/// <reference path="../../../TileMaps/SquareTileMap.ts" />
/// <reference path="../../../TileMaps/ITileDetails.ts" />
/// <reference path="../../../../Graphics/TileMaps/SquareTileMap.ts" />
/// <reference path="../../../../Graphics/TileMaps/ITileDetails.ts" />
/// <reference path="../../../../Assets/TimeSpan.ts" />
/// <reference path="../../../../Extensions/Helpers.ts" />
/// <reference path="../../../../Utilities/EventHandler1.ts" />
Expand Down Expand Up @@ -95,7 +95,7 @@ var EndGate;
});

for (var i = 0; i < tilesets.length; i++) {
sources = Map.SquareTileMap.ExtractTiles(tilesetSources[tilesets[i].name], tilesets[i].tilewidth, tilesets[i].tileheight);
sources = EndGate.Graphics.SquareTileMap.ExtractTiles(tilesetSources[tilesets[i].name], tilesets[i].tilewidth, tilesets[i].tileheight);

for (var property in tilesets[i].properties) {
if (typeof propertyHooks.ResourceSheetHooks[property] !== "undefined") {
Expand Down Expand Up @@ -136,7 +136,7 @@ var EndGate;
var _this = this;
setTimeout(function () {
// Convert the layer data to a 2 dimensional array and subtract 1 from all the data points (to make it 0 based)
var tmxLayer = tmxData.layers[layerIndex], mappings = _this.NormalizeLayerData(tmxLayer.data, tmxData.width), layer = new Map.SquareTileMap(tmxLayer.x, tmxLayer.y, tmxData.tilewidth, tmxData.tileheight, resources.Resources, mappings), layerHooks = new Array();
var tmxLayer = tmxData.layers[layerIndex], mappings = _this.NormalizeLayerData(tmxLayer.data, tmxData.width), layer = new EndGate.Graphics.SquareTileMap(tmxLayer.x, tmxLayer.y, tmxData.tilewidth, tmxData.tileheight, resources.Resources, mappings), layerHooks = new Array();

for (var property in tmxLayer.properties) {
if (typeof propertyHooks.LayerHooks[property] !== "undefined") {
Expand Down
Loading

0 comments on commit 289770f

Please sign in to comment.