Permalink
Browse files

Updated documentation to remove path leakage

  • Loading branch information...
1 parent e7a2ccb commit 9dbfe82bbdc53f048c7a11c0beeed822f96c5dc8 @ajbkr committed Dec 10, 2011
View
1 .gitignore
@@ -1 +1,2 @@
*.swp
+jsdoc.sh
View
6 doc/files.html
@@ -201,7 +201,7 @@ <h1 class="classTitle">File Index</h1>
<div>
- <h2><a href="symbols/src/_home_ajb_src_Steppe_js_Steppe_Compositor.js.html">/home/ajb/src/Steppe/js/Steppe/Compositor.js</a></h2>
+ <h2><a href="symbols/src/js_Steppe_Compositor.js.html">js/Steppe/Compositor.js</a></h2>
<dl>
@@ -213,7 +213,7 @@ <h1 class="classTitle">File Index</h1>
<hr />
<div>
- <h2><a href="symbols/src/_home_ajb_src_Steppe_js_Steppe_Renderer.js.html">/home/ajb/src/Steppe/js/Steppe/Renderer.js</a></h2>
+ <h2><a href="symbols/src/js_Steppe_Renderer.js.html">js/Steppe/Renderer.js</a></h2>
<dl>
@@ -228,7 +228,7 @@ <h1 class="classTitle">File Index</h1>
</div>
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:17 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:04 GMT-0000 (GMT)
</div>
</body>
</html>
View
2 doc/index.html
@@ -228,7 +228,7 @@ <h1 class="classTitle">Class Index</h1>
</div>
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:17 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blankt">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:04 GMT-0000 (GMT)
</div>
</body>
</html>
View
4 doc/symbols/Steppe.Compositor.html
@@ -217,7 +217,7 @@ <h1 class="classTitle">
- <br /><i>Defined in: </i> <a href="../symbols/src/_home_ajb_src_Steppe_js_Steppe_Compositor.js.html">Compositor.js</a>.
+ <br /><i>Defined in: </i> <a href="../symbols/src/js_Steppe_Compositor.js.html">Compositor.js</a>.
</p>
@@ -655,7 +655,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:17 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:04 GMT-0000 (GMT)
</div>
</body>
</html>
View
107 doc/symbols/Steppe.Renderer.html
@@ -217,7 +217,7 @@ <h1 class="classTitle">
- <br /><i>Defined in: </i> <a href="../symbols/src/_home_ajb_src_Steppe_js_Steppe_Renderer.js.html">Renderer.js</a>.
+ <br /><i>Defined in: </i> <a href="../symbols/src/js_Steppe_Renderer.js.html">Renderer.js</a>.
</p>
@@ -265,7 +265,7 @@ <h1 class="classTitle">
<tr>
<td class="attributes">&lt;static&gt; &nbsp;</td>
<td class="nameDescription">
- <div class="fixedFont">Steppe.Renderer.<b><a href="../symbols/Steppe.Renderer.html#.addSprite">addSprite</a></b>(image, x, z)
+ <div class="fixedFont">Steppe.Renderer.<b><a href="../symbols/Steppe.Renderer.html#.addSprite">addSprite</a></b>(image, x, y, z)
</div>
<div class="description">Add a 2D sprite, at the specified world coords, to the sprite
list.</div>
@@ -323,7 +323,8 @@ <h1 class="classTitle">
<td class="nameDescription">
<div class="fixedFont">Steppe.Renderer.<b><a href="../symbols/Steppe.Renderer.html#.render">render</a></b>()
</div>
- <div class="description">Render the terrain (landscape) including the sky.</div>
+ <div class="description">Render the terrain (landscape) including the sky and any visible
+sprites.</div>
</td>
</tr>
@@ -339,6 +340,15 @@ <h1 class="classTitle">
<tr>
<td class="attributes">&lt;static&gt; &nbsp;</td>
<td class="nameDescription">
+ <div class="fixedFont">Steppe.Renderer.<b><a href="../symbols/Steppe.Renderer.html#.setFogColor">setFogColor</a></b>(cssColor)
+ </div>
+ <div class="description">..</div>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="attributes">&lt;static&gt; &nbsp;</td>
+ <td class="nameDescription">
<div class="fixedFont">Steppe.Renderer.<b><a href="../symbols/Steppe.Renderer.html#.setHeightmap">setHeightmap</a></b>(heightmap)
</div>
<div class="description">Set the heightmap to use for terrain rendering.</div>
@@ -468,7 +478,7 @@ <h1 class="classTitle">
<div class="fixedFont">&lt;static&gt;
<span class="light">{Renderer}</span>
- <span class="light">Steppe.Renderer.</span><b>addSprite</b>(image, x, z)
+ <span class="light">Steppe.Renderer.</span><b>addSprite</b>(image, x, y, z)
</div>
<div class="description">
@@ -485,7 +495,7 @@ <h1 class="classTitle">
<dt class="heading">Parameters:</dt>
<dt>
- <span class="light fixedFont">{Image}</span> <b>image</b>
+ <span class="light fixedFont">{HTMLImageElement}</span> <b>image</b>
</dt>
<dd>The 2D sprite as an image.</dd>
@@ -497,6 +507,12 @@ <h1 class="classTitle">
<dd>The x-coordinate in world space.</dd>
<dt>
+ <span class="light fixedFont">{number}</span> <b>y</b>
+
+ </dt>
+ <dd>The y-coordinate in world space.</dd>
+
+ <dt>
<span class="light fixedFont">{number}</span> <b>z</b>
</dt>
@@ -511,7 +527,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -557,7 +573,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -603,7 +619,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -636,8 +652,8 @@ <h1 class="classTitle">
<dt class="heading">Returns:</dt>
<dd><span class="light fixedFont">{object}</span> An object composed of an angle-of-rotation (in
- 'fake' degrees) about the y-axis and a 3D point
- in world space.</dd>
+ degrees about the y-axis) and a 3D point in
+ world space.</dd>
</dl>
@@ -752,7 +768,8 @@ <h1 class="classTitle">
</div>
<div class="description">
- Render the terrain (landscape) including the sky.
+ Render the terrain (landscape) including the sky and any visible
+sprites.
</div>
@@ -804,7 +821,50 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
+
+ </dl>
+
+
+
+
+ <hr />
+
+ <a name=".setFogColor"> </a>
+ <div class="fixedFont">&lt;static&gt;
+
+ <span class="light">{Renderer}</span>
+ <span class="light">Steppe.Renderer.</span><b>setFogColor</b>(cssColor)
+
+ </div>
+ <div class="description">
+ ...
+
+
+ </div>
+
+
+
+
+ <dl class="detailList">
+ <dt class="heading">Parameters:</dt>
+
+ <dt>
+ <span class="light fixedFont">{string}</span> <b>cssColor</b>
+
+ </dt>
+ <dd>...</dd>
+
+ </dl>
+
+
+
+
+
+ <dl class="detailList">
+ <dt class="heading">Returns:</dt>
+
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -848,7 +908,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -892,7 +952,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -936,7 +996,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -981,7 +1041,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -993,7 +1053,7 @@ <h1 class="classTitle">
<a name=".setSky"> </a>
<div class="fixedFont">&lt;static&gt;
-
+ <span class="light">{Renderer}</span>
<span class="light">Steppe.Renderer.</span><b>setSky</b>(skyCanvas)
</div>
@@ -1022,6 +1082,13 @@ <h1 class="classTitle">
+ <dl class="detailList">
+ <dt class="heading">Returns:</dt>
+
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
+
+ </dl>
+
@@ -1062,7 +1129,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -1107,7 +1174,7 @@ <h1 class="classTitle">
<dl class="detailList">
<dt class="heading">Returns:</dt>
- <dd><span class="light fixedFont">{Renderer}</span> This (fluent interface).</dd>
+ <dd><span class="light fixedFont">{Renderer}</span> This (chainable).</dd>
</dl>
@@ -1128,7 +1195,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:17 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:04 GMT-0000 (GMT)
</div>
</body>
</html>
View
4 doc/symbols/Steppe.html
@@ -217,7 +217,7 @@ <h1 class="classTitle">
Steppe
- <br /><i>Defined in: </i> <a href="../symbols/src/_home_ajb_src_Steppe_js_Steppe_Renderer.js.html">Renderer.js</a>.
+ <br /><i>Defined in: </i> <a href="../symbols/src/js_Steppe_Renderer.js.html">Renderer.js</a>.
</p>
@@ -310,7 +310,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:16 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:04 GMT-0000 (GMT)
</div>
</body>
</html>
View
2 doc/symbols/_global_.html
@@ -249,7 +249,7 @@ <h1 class="classTitle">
<!-- ============================== footer ================================= -->
<div class="fineprint" style="clear:both">
- Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Tue Jul 26 2011 19:50:16 GMT+0100 (BST)
+ Documentation generated by <a href="http://code.google.com/p/jsdoc-toolkit/" target="_blank">JsDoc Toolkit</a> 2.4.0 on Sat Dec 10 2011 19:41:03 GMT-0000 (GMT)
</div>
</body>
</html>
View
1,089 doc/symbols/src/_home_ajb_src_Steppe_js_Steppe_Renderer.js.html
0 additions, 1,089 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
0 ...b_src_Steppe_js_Steppe_Compositor.js.html → doc/symbols/src/js_Steppe_Compositor.js.html
File renamed without changes.
View
1,350 doc/symbols/src/js_Steppe_Renderer.js.html
1,350 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
158 js/Steppe/Renderer.js
@@ -46,7 +46,8 @@ var Steppe = (function(Steppe) {
_spriteList = [],
_temporaryFramebuffer,
_texturemap,
- _visibleSpriteList = [];
+ _visibleSpriteList = [],
+ _zBuffer = [];
var _fog = false, // disabled (default)
_quality = _DONT_CARE, // medium quality (default)
@@ -359,24 +360,23 @@ var Steppe = (function(Steppe) {
bottom = 199;
}
- var index, j, i;
+ var index, i, j;
if (ray > _quality) {
// Not the left-most ray...
index =
(top * (framebufferImageData.width << 2)) +
(ray << 2);
+ var red = (color >> 24) & 0xff,
+ green = (color >> 16) & 0xff,
+ blue = (color >> 8) & 0xff;
+
for (j = 0; j < bottom - top + 1; ++j) {
for (i = 0; i < _quality; ++i) {
- framebufferData[index] =
- (color >> 24) & 0xff;
- framebufferData[index + 1] =
- (color >> 16) & 0xff;
- framebufferData[index + 2] =
- (color >> 8) & 0xff;
- framebufferData[index + 3] = 0xff;
-
- index += 4;
+ framebufferData[index] = red;
+ framebufferData[++index] = green;
+ framebufferData[++index] = blue;
+ framebufferData[++index] = 0xff;
}
index += (framebufferImageData.width << 2) -
@@ -388,26 +388,25 @@ var Steppe = (function(Steppe) {
(top * (framebufferImageData.width << 2)) +
(ray << 2);
+ red = (color >> 24) & 0xff;
+ green = (color >> 16) & 0xff;
+ blue = (color >> 8) & 0xff;
+
for (j = 0; j < bottom - top + 1; ++j) {
for (i = 0; i < _quality; ++i) {
framebufferData[index - (_quality << 2)] =
- (color >> 24) & 0xff;
+ red;
framebufferData[index - (_quality << 2) + 1] =
- (color >> 16) & 0xff;
+ green;
framebufferData[index - (_quality << 2) + 2] =
- (color >> 8) & 0xff;
+ blue;
framebufferData[index - (_quality << 2) + 3] =
0xff;
- framebufferData[index] =
- (color >> 24) & 0xff;
- framebufferData[index + 1] =
- (color >> 16) & 0xff;
- framebufferData[index + 2] =
- (color >> 8) & 0xff;
- framebufferData[index + 3] = 0xff;
-
- index += 4;
+ framebufferData[index] = red;
+ framebufferData[++index] = green;
+ framebufferData[++index] = blue;
+ framebufferData[++index] = 0xff;
}
index += (framebufferImageData.width << 2) -
@@ -569,17 +568,16 @@ var Steppe = (function(Steppe) {
(top * (framebufferImageData.width << 2)) +
(ray << 2);
+ var red = (color >> 24) & 0xff,
+ green = (color >> 16) & 0xff,
+ blue = (color >> 8) & 0xff;
+
for (j = 0; j < bottom - top + 1; ++j) {
for (i = 0; i < _quality; ++i) {
- framebufferData[index] =
- (color >> 24) & 0xff;
- framebufferData[index + 1] =
- (color >> 16) & 0xff;
- framebufferData[index + 2] =
- (color >> 8) & 0xff;
- framebufferData[index + 3] = 0xff;
-
- index += 4;
+ framebufferData[index++] = red;
+ framebufferData[index++] = green;
+ framebufferData[index++] = blue;
+ framebufferData[index++] = 0xff;
}
index += (framebufferImageData.width << 2) -
@@ -591,30 +589,28 @@ var Steppe = (function(Steppe) {
(top * (framebufferImageData.width << 2)) +
(ray << 2);
+ red = (color >> 24) & 0xff;
+ green = (color >> 16) & 0xff;
+ blue = (color >> 8) & 0xff;
+
for (j = 0; j < bottom - top + 1; ++j) {
for (i = 0; i < _quality; ++i) {
framebufferData[index -
- (_quality << 2)] =
- (color >> 24) & 0xff;
+ (_quality << 2)] = red;
framebufferData[index -
- (_quality << 2) + 1] =
- (color >> 16) & 0xff;
+ (_quality << 2) + 1] = green;
framebufferData[index -
- (_quality << 2) + 2] =
- (color >> 8) & 0xff;
+ (_quality << 2) + 2] = blue;
framebufferData[index -
(_quality << 2) + 3] =
0xff;
- framebufferData[index] =
- (color >> 24) & 0xff;
- framebufferData[index + 1] =
- (color >> 16) & 0xff;
- framebufferData[index + 2] =
- (color >> 8) & 0xff;
- framebufferData[index + 3] = 0xff;
+ framebufferData[index++] = red;
+ framebufferData[index++] = green;
+ framebufferData[index++] = blue;
+ framebufferData[index++] = 0xff;
- index += 4;
+// index += 4;
}
index += (framebufferImageData.width << 2) -
@@ -698,6 +694,51 @@ var Steppe = (function(Steppe) {
}
};
+ /**
+ * ...
+ */
+ var _renderSprites = function() {
+ // For each visible sprite...
+ for (var i = 0; i < _visibleSpriteList.length; ++i) {
+ // If the current sprite has been removed...
+ if (_visibleSpriteList[i] === undefined) {
+ // Move to the next sprite.
+ continue;
+ }
+
+ var sprite = _visibleSpriteList[i];
+
+ // Draw the sprite.
+ _framebuffer.drawImage(
+ sprite.image,
+ sprite.x,
+ sprite.y - _smooth,
+ sprite.width,
+ sprite.height);
+
+ // Remove the sprite from the list of visible sprites.
+ _visibleSpriteList[i] = undefined;
+ }
+ };
+
+ /**
+ * ...
+ */
+ var _sortVisibleSpriteList = function() {
+ var length = _visibleSpriteList.length;
+
+ for (var i = 0; i < length - 1; ++i) {
+ for (var j = i + 1; j < length; ++j) {
+ if (_visibleSpriteList[j].vectorLength >
+ _visibleSpriteList[i].vectorLength) {
+ var temp = _visibleSpriteList[i];
+ _visibleSpriteList[i] = _visibleSpriteList[j];
+ _visibleSpriteList[j] = temp;
+ }
+ }
+ }
+ };
+
if (arguments.length > 1) {
throw('Too many arguments passed to constructor');
}
@@ -728,34 +769,38 @@ var Steppe = (function(Steppe) {
*
* @param {HTMLImageElement} image The 2D sprite as an image.
* @param {number} x The x-coordinate in world space.
+ * @param {number} y The y-coordinate in world space.
* @param {number} z The z-coordinate in world space.
* @return {Renderer} This (chainable).
*/
- addSprite: function(image, x, z) {
+ addSprite: function(image, x, y, z) {
if ( !(image instanceof HTMLImageElement)) {
throw('Invalid image: not an instance of HTMLImageElement');
}
if (typeof(x) != 'number') {
throw('Invalid x: not a number');
}
+ if (typeof(y) != 'number') {
+ throw('Invalid y: not a number');
+ }
if (typeof(z) != 'number') {
throw('Invalid z: not a number');
}
if (x < 1024 || x >= 1024 + 1024) {
throw('Invalid x: must be in the range 1024..2047');
}
+ if (y < 0 || y >= 1024) {
+ throw('Invalid y: must be in the range 0..1023');
+ }
if (z < 1024 || z >= 1024 + 1024) {
throw('Invalid z: must be in the range 1024..2047');
}
- var u = x & 1023;
- var v = z & 1023;
-
_spriteList.push({
image: image,
x: x,
- y: _heightmap[(v << 10) + u],
+ y: y & 1023,
z: z
});
@@ -1022,6 +1067,11 @@ var Steppe = (function(Steppe) {
}
}
+ _sortVisibleSpriteList();
+/* for (var k = 0; k < _visibleSpriteList.length; ++k) {
+ console.log(_visibleSpriteList[k].vectorLength);
+ }*/
+
var initialAngle = _camera.angle - _THIRTY_DEGREE_ANGLE;
if (initialAngle < 0) {
@@ -1036,7 +1086,9 @@ var Steppe = (function(Steppe) {
// If there are sprites in view...
if (_visibleSpriteList.length > 0) {
// Render the terrain /with/ sprites back-to-front.
- _renderBackToFront(initialAngle);
+// _renderBackToFront(initialAngle);
+ _renderFrontToBack(initialAngle);
+ _renderSprites();
} else {
// Render the terrain front-to-back. NOTE: This method is
// considerably faster!
@@ -1197,7 +1249,7 @@ var Steppe = (function(Steppe) {
} else if (quality === 'high') {
_quality = _NICEST;
} else {
- throw("Invalid quality; must be 'low', 'medium', " +
+ throw("Invalid quality: must be 'low', 'medium', " +
"or 'high'");
}

0 comments on commit 9dbfe82

Please sign in to comment.