<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Atomic Monks, LLC — Articles]]></title>
		<link>http://forums.atomicmonks.com/</link>
		<atom:link href="http://forums.atomicmonks.com/feed/rss/forum/32/" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent topics at Atomic Monks, LLC.]]></description>
		<lastBuildDate>Sat, 15 Nov 2008 01:44:35 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Pathfinding in JavaScript]]></title>
			<link>http://forums.atomicmonks.com/topic/1023/pathfinding-in-javascript/new/posts/</link>
			<description><![CDATA[<p>A few months ago I was testing out several methods of finding the most efficient path between two points on a grid...pathfinding. This was for combat mode in the Muties game, and it was much faster to fiddle with it all in JavaScript instead of PHP (where the final version now resides).</p><p>For the curious, <a href="http://www.atomicmonks.com/path.html">here is the test page</a> that I was using to test it. Everything needed is on that page (scripts included). If you have any specific questions about what you find there, post a comment and I&#039;ll do my best to answer.</p><p>Oh, obviously you&#039;ll need to have JavaScript enabled. The page was tested in Firefox, IE7, and Chrome.</p><p>Right-click to set the green point, and shift+right-click to set the red point.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Sat, 15 Nov 2008 01:44:35 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/1023/pathfinding-in-javascript/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[An int is an int is an int...isn't it?]]></title>
			<link>http://forums.atomicmonks.com/topic/993/an-int-is-an-int-is-an-intisnt-it/new/posts/</link>
			<description><![CDATA[<p>For some reason I&#039;m considered the &quot;JavaScript Guru&quot; where I work, which I suppose is a sort of honor in a company that large. Another employee (let&#039;s call him &quot;Bob&quot;) asked me to come down and help him solve a problem he was having with a bit of JavaScript.</p><p>I came down, and he explained what he was trying to do. He had a date (08/14/2008) coming in as simple text, and needed to break it apart into month/day/year. So he took the first two characters of his date to get the month, the 4th and 5th characters for the day, and so on. He was then converting those smaller bits of text into numbers (&quot;08&quot; into 8, &quot;14&quot; into 14, etc.). Problem is, he was getting zero for the month.</p><br /><p>Some of you may have already guessed that he was doing the following to get his numbers:<br /></p><div class="codebox"><pre><code>var month = parseInt(monthString);</code></pre></div><p>Instead of eight, it was returning zero. As soon as I saw it, I remembered the last time that had snuck up and bitten me in the butt. I changed his code to:<br /></p><div class="codebox"><pre><code>var month = parseInt(monthString, 10);</code></pre></div><p>...and it gave him the eight he expected.</p><p>Oddly, most examples of parseInt you&#039;ll find on the web completely skip the second parameter: the <em>radix</em>. The radix tells parseInt what number base to use. So a binary example might be:<br /></p><div class="codebox"><pre><code>var num = parseInt(&#039;010110&#039;, 2);</code></pre></div><p>And of course you could use it to convert hexadecimal:<br /></p><div class="codebox"><pre><code>var num = parseInt(&#039;8AFA&#039;, 16);</code></pre></div><p>But, you ask, why does &quot;08&quot; come up as zero when you don&#039;t specify a radix? Shouldn&#039;t it default to 10, like any human would expect?</p><p>What it actually does when you don&#039;t specify the radix is try to guess based on the text you give it. And when you remember that JavaScript takes quite a bit from C, it starts to make sense. In C, if you start a number with &quot;0x&quot;, then it&#039;s read as hexadecimal. If you start with a zero, it interprets it as octal (base 8). Really, this is all a carryover from C. &quot;08&quot; has a leading zero, so it&#039;s treated as octal, but there is no &quot;8&quot; in octal...it only goes from zero to seven. So you get a zero back. You&#039;ll get the same thing from &quot;09&quot;. Extra credit if you know what &quot;010&quot; will get you!</p><p>This is one of those sneaky things that can really bite you when you least expect it. Awareness can save you, but so can using a JavaScript framework like jQuery, or <a href="http://www.mootools.net">MooTools</a>. They have helper functions to handle this for you in a standard way. Either way, you should now know how to keep this from biting you in your own code.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Sun, 24 Aug 2008 02:36:43 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/993/an-int-is-an-int-is-an-intisnt-it/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[The Staff]]></title>
			<link>http://forums.atomicmonks.com/topic/356/the-staff/new/posts/</link>
			<description><![CDATA[<p><strong>BROTHER CARL</strong> (Most Holy Illuminator)</p><p>Carl is a graphic artist by trade, and a good one to boot. Look to the logo for proof...it&#039;s a Carl original.</p><p><strong>BROTHER DALE</strong> (Most Unholy and Occasional Scribe)</p><p>Dale is supposed a tester, but we haven&#039;t gotten any testing out of him yet. He is at least partly responsible for the very existence of WordWars. A very random brainstorming session between him and Erryn resulted in a rough plan for the game.<br /><strong><br />BROTHER ERRYN</strong> (<a href="mailto:brothererryn@atomicmonks.com">Head Technomancer of the Order</a>)</p><p>Erryn is the lead programmer for Atomic Monks. In addition to developing for us, he is a full time software developer that uses C++, VB/VBScript, ASP, Javascript, Logo, Fortran, Cobol, and several other archaic languages he deems too painful to mention. At the moment, he is also the webmaster.</p><p><strong>BROTHER GEORGE</strong> (Most Holy Verifier of Notions)</p><p>George is one of our testers, always willing to throw himself at the mercy of yet another computer game. He has a good head for what makes a game fun, so it&#039;s good to throw our ideas at him and see if they stick.</p><p><strong>BROTHER JEFF</strong> (<a href="mailto:brotherjeff@atomicmonks.com">Most Holy Writer of the Holy Word</a>)</p><p>Jeff is a debugger for Atomic Monks, and suffers the misfortune of working with Erryn on a daily basis. He is very helpful in tracking down strange bugs, and tests the game a lot. Mostly because he likes blowing things up. The development of WordWars saw him primarily as a tester, but it was also used to bring him slowly up to speed on game programming. He&#039;s a real whiz with SQL Server, and will be a primary developer on Rogue.</p><p><strong>BROTHER JEFFY</strong> (Brother of the Unholy Rage)</p><p>Jeff is yet another springboard for our game ideas. He frequently resembles an ogre in a beserker frenzy...and likes it.</p><p><strong>BROTHER JOHN</strong> (Most Holy Planner of Doom)</p><p>John is the &quot;serious&quot; wargamer of the group. &quot;If it doesn&#039;t have hexes, it&#039;s not a real game&quot; comes to mind. He also possesses the ancient ninja secret of invisibility. Go ahead, try and find him. He is currently serving his country somewhere in the Middle East, but we hope to have him back with us soon, safe and sound.</p><p><strong>BROTHER X</strong> (<a href="mailto:contact@atomicmonks.com">Most Holy Monk of Mystery</a>)</p><p>We&#039;re not sure who this is, but people seem to email him for general questions and comments.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Wed, 07 Dec 2005 15:21:46 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/356/the-staff/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Timing Part II]]></title>
			<link>http://forums.atomicmonks.com/topic/351/timing-part-ii/new/posts/</link>
			<description><![CDATA[<p><strong>Timing Part II:</strong> Timers in VB.NET</p><p>In a previous article, we talked about different timers available to VB6. With the move to .NET, this needs to be updated...or does it. In this article, we&#039;ll take a look at timing options in VB.NET.VB.NET exposes some new timing methods: Environment.TickCount and System.DateTime.Now.Ticks.</p><p>TickCount is a virtual clone of the old GetTickCount API call and returns the &quot;amount of time in milliseconds that has passed since the last time the computer was started.&quot;</p><p>Ticks gives you &quot;the number of 100-nanosecond intervals that have elapsed since 12:00 A.M., January 1, 0001.&quot;</p><p>One could also use the old favorites QueryPerformanceCounter and timeGetTime via the standard &quot;Declare Function x Lib y&quot; format, but we like to do things .NET-style.</p><p>TickCount has millisecond resolution, while Ticks has 0.0001 millisecond resolution. One would think, therefore, that Ticks would be a wonderfully accurate way to go. But it, like every other timer except QPC, doesn&#039;t have the accuracy to match its resolution. That is to say, while Ticks specifies nanoseconds, its value is actually only updated every 15 to 30 milliseconds. Thus it really isn&#039;t any better. (Whidbey will include the System.Diagnostics.Stopwatch class, which looks promising.)</p><p>The way around this pitfall in VB6 was to call timeBeginPeriod and timeEndPeriod. With those, you could specify an accuracy of 1 ms to match the 1 ms resolution of timeGetTime. Interestingly, this article at Microsoft mentions that D3DPRESENT_INTERVAL_ONE actually sets timeBeginPeriod(1) &quot;to enhance timer resolution&quot;. The catch is, timeBeginPeriod doesn&#039;t seem to affect TickCount or Ticks accuracy at all.</p><p>Our solution? We added these lines to our engine:<br /></p><div class="codebox"><pre><code>    Private Declare Function timeGetTime Lib &quot;winmm.dll&quot; () As Integer
    Private Declare Function timeBeginPeriod Lib &quot;winmm.dll&quot; (ByVal uPeriod As Integer) As Integer
    Private Declare Function timeEndPeriod Lib &quot;winmm.dll&quot; (ByVal uPeriod As Integer) As Integer</code></pre></div><p>That&#039;s right, we&#039;re using the old multimedia API calls for our timing, and they&#039;re working like a charm. timeBeginPeriod(1) is called in the engine&#039;s New, and timeEndPeriod(1) in the Finalize. timeGetTime is used for timing in between.</p><p>Anybody else have other experiences with timing in .NET? Drop a comment.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Wed, 07 Dec 2005 14:46:36 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/351/timing-part-ii/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Higher Precision Timers]]></title>
			<link>http://forums.atomicmonks.com/topic/350/higher-precision-timers/new/posts/</link>
			<description><![CDATA[<p><strong>Higher Precision Timers:</strong> A Better, But Not Excessive Timer</p><p>When doing time-based animation, you have several options for tracking the amount of time that has passed between frames:</p><p> * Timer Control<br /> * Timer object<br /> * GetTickCount (API)<br /> * timeGetTime (API)<br /> * QueryPerformanceCounter (API)[/list]</p><p>The first four are not very precise, and the fourth has a tendency to suddenly jump ahead a few seconds to correct itself. So what&#039;s a programmer to do? Cheat.</p><p>You can set the timer control to an interval of one, but it&#039;s accuracy is at best 55 ms. The timer function only returns hundredths. GetTickCount reports ms, but is also only accurate to 12-58 (depending on OS) ms, and timeGetTime&#039;s resolution seems to vary by machine (15.625 ms resolution on my development rig, about 30 ms on another). QueryPerformanceCounter is incredibly precise...but can suddenly jump ahead several seconds to correct itself, and without warning.</p><p>On the surface, you might think GetTickCount or timeGetTime might be the way to go. After all, 15.625 ms should be plenty fast, right? Even 30 ms seems good. That is, until you do a little math:</p><p>1 sec / 15.625ms = 64 FPS 1 sec / 30.000ms = 33.333 FPS</p><p>Note that you might actually draw MORE than 64 FPS, but any animation will only be updated 64 FPS, which is actually noticeable. The discrepancy will cause strange hops and jumps in your animation, since you&#039;ll get numerous frames where the timers tell you that no time has passed since the last frame. If no time has passed, no changes are made and the exact same frame is drawn again.</p><p>Envision this scenario: 14 ms has passed since the last frame, so the timer tells you no time has passed at all (not up to 15.625 ms yet). The next time around, Windows took a little bit and an additional 18 ms has passed. The timer tells you that 32 ms has passed since the last frame, and your animation plays catch-up. On a slower machine (IE: 30 ms resolution...or even 58), this jump becomes REALLY noticeable. Given that on a decent machine a single frame could be handled in 2 or 3 ms, we&#039;re missing out on a lot of potential smoothness. What we really need is a reliable timer with 1 ms precision or so. Fortunately, that&#039;s what we have with timeGetTime.</p><p>What&#039;s that? I said that timeGetTime is only accurate to 15 ms or so? Well, that&#039;s true...by default. It&#039;s actually accurate to 1 ms, but is updated much less often! Happily, we do have a way to correct this.<br /></p><div class="codebox"><pre><code>    Public Declare Function timeBeginPeriod Lib &quot;winmm.dll&quot; (ByVal uPeriod As Long) As Long
    Public Declare Function timeEndPeriod Lib &quot;winmm.dll&quot; (ByVal uPeriod As Long) As Long</code></pre></div><p>These two API calls were surprisingly difficult to find out about, and they&#039;re not in the API-Guide.</p><p>At the beginning of your code, you make this call:<br /></p><div class="codebox"><pre><code>    timeBeginPeriod 1</code></pre></div><p>This sets the update period of timeGetTime to 1 ms.</p><p>When your program is exiting, you make this call:<br /></p><div class="codebox"><pre><code>    timeEndPeriod 1</code></pre></div><p>This restores the update period of timeGetTime to whatever it was when you started.</p><p>Between these two calls, your calls to timeGetTime are actually accurate to 1 ms, and all is well. For most applications, this is more than enough.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Wed, 07 Dec 2005 14:45:37 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/350/higher-precision-timers/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[CXMLINI Class]]></title>
			<link>http://forums.atomicmonks.com/topic/349/cxmlini-class/new/posts/</link>
			<description><![CDATA[<p><strong>CXMLINI Class:</strong> A Replacement for INI Files in VB.NET</p><p>In VB6, one way to store data has long been the elderly INI file. Since Windows 95, Microsoft has pushed hard to get rid of the INI file, and move that data into the registry. Many developers are wary of that approach, fearful of contributing to the &quot;clutter&quot; of the registry. So the INI file has survived despite Microsoft&#039;s best efforts.</p><p>And there are other advantages to an INI file. In Rogue, it holds video settings, key mappings, and more. It&#039;s much quicker to open Notepad and change an INI file than it is to modify registry entries. But INI support in .NET falls outside of managed code...so if you want a &quot;real&quot; .NET way of doing this, you need to go to XML.</p><p>Let&#039;s look at the video section of Rogue&#039;s INI file:<br /></p><div class="codebox"><pre><code>[Video]
Height=768
Width=1024
Windowed=1
TripleBuffer=0</code></pre></div><p>And the XML file for the same entries:<br /></p><div class="codebox"><pre><code>&lt;sections&gt;
  &lt;section name=&quot;video&quot;&gt;
    &lt;item key=&quot;Width&quot; value=&quot;800&quot; /&gt;
    &lt;item key=&quot;Height&quot; value=&quot;600&quot; /&gt;
    &lt;item key=&quot;Windowed&quot; value=&quot;1&quot; /&gt;
    &lt;item key=&quot;TripleBuffer&quot; value=&quot;0&quot; /&gt;
  &lt;/section&gt;
&lt;/sections&gt;</code></pre></div><p>The structure is easy enough to follow, and is modelled after the INI file structure (different sections, with numerous key/value sets). The hard part of dealing with the XML itself will be handled by the xmlDocument object.</p><p>Let&#039;s first take a look at the class declarations and the New procedure(s):<br /></p><div class="codebox"><pre><code>Public Class CXMLINI

    Private doc As New Xml.XmlDocument
    Private xmlfile As String

    Public Sub New(ByVal Filename As String)
        &#039; open xml file for use
        Try
            doc.Load(Filename)
            xmlfile = Filename
        Catch ex As Exception
        End Try
    End Sub

    Public Sub New()
        &#039; open default xml file for use
        Dim s As String

        s = System.AppDomain.CurrentDomain.BaseDirectory
        s &amp;= Application.ProductName
        s &amp;= &quot;.xml&quot;

        Try
            doc.Load(s)
            xmlfile = s
        Catch ex As Exception
        End Try
    End Sub</code></pre></div><p><strong>doc </strong>is the xmlDocument object for the class, which we&#039;ll maintain until the class is destroyed. This object stores the contents of the xml file we load in memory, where we can almost treat it like a dataset.</p><p>Notice that I&#039;ve overloaded the New procedure. When given a filename, it opens that xml file. Otherwise, it defaults to Application Name.xml. In either case, if the file doesn&#039;t exist, it catches the error and goes on, but remembers the file name that it was supposed to use (for later use).</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Wed, 07 Dec 2005 14:40:53 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/349/cxmlini-class/new/posts/</guid>
		</item>
		<item>
			<title><![CDATA[Bitmap Fonts]]></title>
			<link>http://forums.atomicmonks.com/topic/348/bitmap-fonts/new/posts/</link>
			<description><![CDATA[<p><strong>Bitmap Fonts: </strong>Using Prerendered Graphics for Text</p><p><strong>NOTE: This tutorial assumes you can handle the basic setup of a D3D/DX project. The code included here can be added to such a project for use. You will also have to work with the code a bit, as it is very much designed to work within our specific project.</strong>&nbsp; Also, accompanying source is available in our downloads section.</p><p>During the initial development of WordWars, we were using the D3DXFont object; it&#039;s very simple and takes very little to set up. As we neared the beta release, the performance became a serious issue. DirectX actually creates multiple polygons per letter to do the text, and does so very inefficiently. This is fine for small amounts of text, but not for long messages (or interactive chat text). DrawText isn&#039;t much better.</p><p>The only real answer was a prerendered font, or bitmap font. Bitmap fonts have the advantage of being very fast, and they can be painted with whatever texture or mix of colors you like. The WordWars metal set uses a &quot;liquid metal&quot; effect for its fonts, as an example. Unfortunately, it can be tricky to draw them where their baselines align correctly, and manually calculating the width of each letter (much less applying that information when drawing them) can be a very trying experience. What finally made us decide to take the plunge into bitmap fonts was the discovery of an excellent free tool: Bitmap Font Builder. </p><p>This tutorial roughly covers the process we use for WordWars&#039; bitmap fonts. Code is also available for download, although it will need a little modification to work in your own program. Our bitmap font engine supports standard D3DXFont alignments (left, top, center, etc.) and a few formatting tags (/COLOR, /NEWLINE). You are welcome to use the provided code for any purpose.</p><p><span class="postimg"><img src="http://www.atomicmonks.com/images/fontbuilder.jpg" alt="http://www.atomicmonks.com/images/fontbuilder.jpg" /></span></p><p>Bitmap Font Builder I stumbled across this on a C++ site, and it can be found at <a href="http://www.lmnopc.com/">http://www.lmnopc.com/</a>. The creator asks for an email telling him what you&#039;re doing with it...and that&#039;s the only cost. Seems fair. </p><p>Bitmap Font Builder gives you many options, but the only one truly important to this tutorial is the texture size of 512x512.</p><p>There is an option to create a bitmap with a full ASCII character set, but the default gives you all the characters you should need. WordWars sets use the latter, with Font 2 set to precisely half the size of Font 1. Create a font bitmap and save the graphic to a tutorial project folder. Record the font sizes you used for later use. Finally, save the font widths to an INI file (in the File menu. Put this file inside your project folder also.</p><p>Next, a look at the ATOMFont code module.</p>]]></description>
			<author><![CDATA[null@example.com (Brother Erryn)]]></author>
			<pubDate>Wed, 07 Dec 2005 14:18:08 +0000</pubDate>
			<guid>http://forums.atomicmonks.com/topic/348/bitmap-fonts/new/posts/</guid>
		</item>
	</channel>
</rss>

