<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paradice Software &#187; Icefall</title>
	<atom:link href="http://www.paradicesoftware.com/blog/index.php/tag/icefall/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.paradicesoftware.com/blog</link>
	<description>Developing a role-playing game since 1981</description>
	<lastBuildDate>Tue, 22 Jun 2010 08:23:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Citadel Beta released!</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2010/03/citadel-beta-released/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2010/03/citadel-beta-released/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 11:01:40 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Citadel]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Beta]]></category>
		<category><![CDATA[Networking]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=206</guid>
		<description><![CDATA[People who know me on Facebook may be aware that I recently took a break from Icefall to focus on networking code.
I plan for networking to form an important part of Icefall&#8217;s gameplay: the game itself is not realtime multiplayer, however I plan for an &#8216;Auction House&#8217;, scoreboards/leaderboards/server-firsts, player-to-player mail, and other online community-type features.
BUT [...]]]></description>
			<content:encoded><![CDATA[<p>People who know me on Facebook may be aware that I recently took a break from Icefall to focus on networking code.</p>
<p>I plan for networking to form an important part of Icefall&#8217;s gameplay: the game itself is not realtime multiplayer, however I plan for an &#8216;Auction House&#8217;, scoreboards/leaderboards/server-firsts, player-to-player mail, and other online community-type features.</p>
<p>BUT I have never worked with any networking code of any complexity before, and I determined that trying to &#8216;learn while I go&#8217; during the Icefall development process would not be the best idea. Hence, Citadel!</p>
<p>Citadel is a &#8216;tower-defense&#8217; game. For those unfamiliar with the concept, essentially an endless wave of bad guys (in this case, tanks, jets, armoured cars, and trikes) try to get to and destroy your tower. Your job is to build a system of defensive towers to prevent them from doing that. The towers themselves automatically aim and fire, the strategy lies in placing the right towers and walls in the right places to do as much damage to the invaders as possible.</p>
<p>Each wave of invaders is tougher than the last, and eventually they will overwhelm your defenses. However, each invader you kill will give you some credits to spend on additional defense, and you receive more credits for tougher invaders. So the object is to last as long as possible, try to save money for the strongest towers (the Tesla Coil), and ultimately get a big score.</p>
<p>As far as tower-defense games go, Citadel currently isn&#8217;t that sophisticated (it&#8217;s a beta version, after all!) and doesn&#8217;t have upgradable towers or multiple game types or anything like that, but it does have a unique feature that I couldn&#8217;t find in any other Tower Defense games anywhere: it can do multiplayer. Get a friend on a LAN, or over the internet (hook up a voice-chat program like MSN or Ventrilo!) and you can join forces to get the highest scores. It&#8217;s competitive co-operative: you share the same base and it&#8217;s game over when an invader reaches it, but who does the most damage to the creates gets the most credits for the kill, and the most score at the end.</p>
<p>NOTE: The invaders MUST ALWAYS HAVE *some way* to get through. Even if they have to go ridiculously long ways around crazily long mazes and queue up single file, it is against the rules of tower defense games to block them off completely. If you do that, it&#8217;s immediately game over!</p>
<p>Try the demo! If you don&#8217;t like it, that&#8217;s fine &#8211; but if it works (especially the networking part), or if it doesn&#8217;t work and you tell me about it and I work with you to make it work, then you&#8217;re helping me to make sure Icefall&#8217;s online components are awesome when they come out!</p>
<div id="attachment_208" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.paradicesoftware.com/blog/wp-content/uploads/2010/03/Citadeltitle.png"><img class="size-medium wp-image-208" title="Citadel - Menu" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2010/03/Citadeltitle-300x225.png" alt="The Citadel Main Menu" width="300" height="225" /></a><p class="wp-caption-text">The Citadel Main Menu</p></div>
<div id="attachment_209" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.paradicesoftware.com/blog/wp-content/uploads/2010/03/Citadelaction.png"><img class="size-medium wp-image-209" title="Citadel - Gameplay" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2010/03/Citadelaction-300x225.png" alt="Early into a Citadel game" width="300" height="225" /></a><p class="wp-caption-text">Early into a Citadel game</p></div>
<p><a href="http://www.paradicesoftware.com/storage/CitadelSetup.exe">Download the beta demo here</a> and let me know in the comments what you think, if it works, or (more importantly!) if it doesn&#8217;t work, or (MOST importantly!) what your high score is <img src='http://www.paradicesoftware.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2010/03/citadel-beta-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icefall Progress</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2010/01/icefall-progress/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2010/01/icefall-progress/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 11:05:31 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=197</guid>
		<description><![CDATA[Long time, no update. My holiday from my real job is almost at an end, but the good news is that I have spent a lot of time with Icefall and it&#8217;s actually starting to come together!
I had developed a lot of separate pieces of game infrastructure (random map generation, character creation, character death&#8230; etc), [...]]]></description>
			<content:encoded><![CDATA[<p>Long time, no update. My holiday from my real job is almost at an end, but the good news is that I have spent a lot of time with Icefall and it&#8217;s actually starting to come together!</p>
<p>I had developed a lot of separate pieces of game infrastructure (random map generation, character creation, character death&#8230; etc), and over the last couple of days I have successfully integrated them all into the main Icefall build. This means that what I have now, for the first time, is a *fully* playable game! You start out creating a character, you can explore, find items, kill monsters, and be killed in turn. </p>
<p>There&#8217;s still thousands of features missing (I had thought I was pretty well progressed on the UI side of things, but now the framework is in place, I can see there are quite a few gaps I need to fill in) but now I have something that feels like a game, I can start iterating on it and trying it out. </p>
<p>The game has killed me several times already &#8211; I have added a few &#8216;tough&#8217; monsters for the deep dungeon, but I haven&#8217;t really added any high-level equipment yet. So it&#8217;s possible for my character to be wearing all the best items in the game and still get owned by the monsters. This will be fixed as I add in more content <img src='http://www.paradicesoftware.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I didn&#8217;t meet my goal of having it completed over Christmas, but at least I have made significant progress. Overall, I&#8217;m pretty happy with how far along it is.</p>
<p>Finally, anyone who has played a roguelike will be very familiar with the death screen. Here&#8217;s Icefall&#8217;s current version (more information about how/when/why you died will be added in future):</p>
 <div id="attachment_200" class="wp-caption aligncenter" style="width: 600px"><img src="http://www.paradicesoftware.com/blog/wp-content/uploads/2010/01/Death.png" alt="The Icefall death screen quickly becomes familiar." title="Death Screen" width="590" height="392" class="size-full wp-image-200" /><p class="wp-caption-text">The Icefall death screen quickly becomes familiar.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2010/01/icefall-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Happy Holidays</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/12/happy-holidays/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/12/happy-holidays/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 09:53:13 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=195</guid>
		<description><![CDATA[Sorry, no posts for a while! I&#8217;m on holiday for Christmas, although I will be spending some time working on finishing up Icefall, I probably won&#8217;t be posting that much.
See you in the new year!
]]></description>
			<content:encoded><![CDATA[<p>Sorry, no posts for a while! I&#8217;m on holiday for Christmas, although I will be spending some time working on finishing up Icefall, I probably won&#8217;t be posting that much.<br />
See you in the new year!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/12/happy-holidays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Assets as Text Files!</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/12/assets-as-text-files/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/12/assets-as-text-files/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 09:42:48 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Good coding guidelines]]></category>
		<category><![CDATA[Icefall]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=191</guid>
		<description><![CDATA[OK, this trick is probably universally known, but I&#8217;ve only just discovered it (by the classic programmer method of reinventing it), so on the chance there are others who are unfamiliar with this technique, it&#8217;s worth describing.
Any sufficiently complex game is going to have &#8220;assets&#8221;: data external to the main program that the game depends [...]]]></description>
			<content:encoded><![CDATA[<p>OK, this trick is probably universally known, but I&#8217;ve only just discovered it (by the classic programmer method of reinventing it), so on the chance there are others who are unfamiliar with this technique, it&#8217;s worth describing.</p>
<p>Any sufficiently complex game is going to have &#8220;assets&#8221;: data external to the main program that the game depends on to function. This includes &#8220;art assets&#8221; (textures, images, music, etc) as well as more application-specific &#8220;data assets&#8221; which contain data in a format unique to your application (e.g. Icefall has &#8220;item types&#8221; of all the different equipment players can find/buy/receive).</p>
<p>Handling art assets is relatively easy: you create/modify them in Photoshop (or equivalent), you save them as PNGs or JPGs, and you&#8217;re done! You might wrap them all up in a custom file format to compress/encrypt/streamline them, but that&#8217;s pretty simple and you can do that at the very end of development.</p>
<p>Data assets are different. There aren&#8217;t any programs around that can edit &#8220;Icefall item types&#8221; files. I need to write my own &#8220;Item Types Editor&#8221;, which understands this format and can load, modify and save it. This leads to two problems:</p>
<p>1. I have to spend time writing an Editor. (the actual format load/save code could be shared with Icefall itself, but there&#8217;s all the UI!).</p>
<p>2. If I ever change the &#8220;item types&#8221; format, all the data I&#8217;ve previously created is now in jeopardy. (What I typically do is modify the &#8217;save&#8217; code only, run the editor and  load each asset (old-code), and re-save it (new-code), then when that&#8217;s done I can modify the &#8216;load&#8217; code.</p>
<p>Depending on the type of data asset, using Asset Text Files may be superior. I DON&#8217;T mean your game should store all of it&#8217;s data assets in plain text (yuck!). Here&#8217;s what I mean:</p>
<p>Whip up a simple plaintext &#8217;syntax&#8217; that stores all of the information you want to include in your data asset. Then,  instead of creating an &#8220;Editor&#8221; with bulky UI code, create a command line utility that can parse your plaintext files and spit out your compiled data asset files. If you borrow your main game code for load/save, all you have to write is the text parser, and that can be as easy as you like: you&#8217;re dictating the syntax it has to interpret.</p>
<p>The BEST part of this system is that it makes changing the format of the assets later on very very easy. Oops, I forgot a field for my item types? No worries. Add the extra field to your text file sources (bringing to bear the full power of your fantastic Programmer Text Editor / IDE you&#8217;re using &#8211; the programmers&#8217; Photoshop), a quick change to the asset compiler to recognise the new format, and hit execute.</p>
<p>You get other benefits too: you can put &#8216;logic&#8217; into your compiler without having to put it in you main game. (e.g. scale the values, dictate whatever &#8220;optional&#8221; or &#8220;Default&#8221; fields, anything!</p>
<p>It doesn&#8217;t work for everything (e.g. Icefall&#8217;s &#8220;Level Map&#8221; is huge and an Editor really is the right option for that) &#8211; but when it&#8217;s appropriate, I have found it works brilliantly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/12/assets-as-text-files/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The quest for an intuitive interface</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/12/the-quest-for-an-intuitive-interface/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/12/the-quest-for-an-intuitive-interface/#comments</comments>
		<pubDate>Fri, 04 Dec 2009 21:09:54 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[UI]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=188</guid>
		<description><![CDATA[One of the hardest bits about creating Icefall was getting the User Interface (UI) just right.
Icefall&#8217;s chief inspirations are &#8220;old-school&#8221; role-playing games like Angband (aka Roguelikes: Nethack, Moria, Omega, ADOM all fall into this category). But these old-school games all rely on essentially a text-mode interface with a myriad of hotkeys. I want to make [...]]]></description>
			<content:encoded><![CDATA[<p>One of the hardest bits about creating Icefall was getting the User Interface (UI) just right.<br />
Icefall&#8217;s chief inspirations are &#8220;old-school&#8221; role-playing games like Angband (aka Roguelikes: Nethack, Moria, Omega, ADOM all fall into this category). But these old-school games all rely on essentially a text-mode interface with a myriad of hotkeys. I want to make Icefall more accessible than that. So I took the UI elements from &#8216;modern&#8217; RPGs like World of Warcraft, Titan Quest, and Dragon Age: Orgins: hotbars, cooldowns, drag &amp; drop.</p>
<p>Of course these &#8216;modern&#8217; interfaces are much more work to get right than a classic keyboard-driven one. Even though I&#8217;ve spent more time on this aspect than any other, it&#8217;s still not perfect. Here&#8217;s an example I found yesterday:</p>
<div id="attachment_189" class="wp-caption aligncenter" style="width: 411px"><img class="size-full wp-image-189" title="Icefall Backpack user interface" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/12/Backpack_armor.png" alt="Icefall Backpack user interface" width="401" height="352" /><p class="wp-caption-text">Icefall Backpack user interface</p></div>
<p>Looks easy enough. To equip the Apprentice Jerkin, players can either click and drag it to their Character Sheet, or else right-click it to equip. The problem: there are two, identical jerkins in the player&#8217;s inventory. Click and drag works fine, but if you right-click the second one, a strange thing happens: the *other* jerkin is equipped instead, and disappears from inventory.</p>
<p>Why? Well, right clicking an item in Icefall triggers a codepath to essentially &#8220;Activate Item: Apprentice Jerkin&#8221;. It&#8217;s set up this way so that players can also drag equipment to their hotbar, and equip it directly from there. All good so far. BUT: internally, the inventory is stored as an array, and is stored from left-to-right, top-to-bottom. So when the &#8220;Activate Item&#8221; codepath is triggered, it goes looking for an Apprentice Jerkin to activate, and it finds the other jerkin (the one in the row above) first &#8211; so it activates it!</p>
<p>A rare situation, a completely logical consequence of the way I implemented right-click behaviour. Technically correct (There are no downfalls to the player if the &#8216;wrong&#8217; jerkin is equipped: they&#8217;re identical by definition) and yet it feels completely wrong and would likely alienate a casual user. So I&#8217;m going to have to find a workaround <img src='http://www.paradicesoftware.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/12/the-quest-for-an-intuitive-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icefall Character Creation</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-character-creation/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-character-creation/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 10:36:38 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Decision]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=179</guid>
		<description><![CDATA[Because screenshots are always interesting, here is a screenshot of the &#8220;Character Creation&#8221; part of Icefall. This is one of the very first screens new players will see, as they opt to begin a new adventure the first thing to do is decide who they&#8217;re going to be. (I deliberately replaced the description text with [...]]]></description>
			<content:encoded><![CDATA[<p>Because screenshots are always interesting, here is a screenshot of the &#8220;Character Creation&#8221; part of Icefall. This is one of the very first screens new players will see, as they opt to begin a new adventure the first thing to do is decide who they&#8217;re going to be. (I deliberately replaced the description text with Latin, don&#8217;t want to give away too many plot points at this stage!)</p>
<div class="mceTemp mceIEcenter">
<div id="attachment_178" class="wp-caption aligncenter" style="width: 641px"><img class="size-full wp-image-178 " title="Character Creation" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/11/CreateChar.png" alt="Icefall Character Creation, Nov 30 2009" width="631" height="314" /><p class="wp-caption-text">Icefall Character Creation, Nov 30 2009</p></div>
</div>
<p>Note: the &#8220;portrait&#8221; is currently a giant, upscaled version of the tiles used for the characters ingame. I would love to have larger character portraits, but my artistic skill just isn&#8217;t there&#8230;. hopefully I will find or convince someone at some point to help out <img src='http://www.paradicesoftware.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h3>Class Selection</h3>
<p>In Icefall, Class is a much more important choice than Race: Race has a few minor effects on stats, starting location, etc, but Class affects how you will approach the game: how you will defeat monsters and complete quests.</p>
<p>I strongly considered a &#8220;class-free&#8221; model, where the player starts with a generic character and shapes it over time just by their choices of equipment and &#8217;specialisations&#8217; (Titan Quest is a good example of this approach), but it made things too complicated, and you don&#8217;t gain too much in the approach anyway: in Titan Quest, if you don&#8217;t specialise correctly, you&#8217;ll end up a sort of &#8220;jack-of-all trades&#8221; type character who is not good enough at any one thing to get very far. So you may as well make the choice up-front, so that you and the game can work together to give you the type of experience you want. Choose a Ranger? Great, I&#8217;m going to give you some ranger-related quests.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-character-creation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Icefall UI Evolution</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-ui-evolution/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-ui-evolution/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 23:25:57 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Decision]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=170</guid>
		<description><![CDATA[Taking a break from coding topics, today&#8217;s post explores how Icefall&#8217;s dialog User Interface (UI) has evolved over the course of it&#8217;s development. My automatic-backup tool keeps every version of Icefall available, so I fired up a few old versions and took some screenshots to illustrate the process.
Original Design

This screenshot is actually from the realtime Icefall [...]]]></description>
			<content:encoded><![CDATA[<p>Taking a break from coding topics, today&#8217;s post explores how Icefall&#8217;s dialog User Interface (UI) has evolved over the course of it&#8217;s development. My automatic-backup tool keeps every version of Icefall available, so I fired up a few old versions and took some screenshots to illustrate the process.</p>
<h3>Original Design</h3>
<p><img class="aligncenter size-medium wp-image-166" title="UI Dialog: Original" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/11/Stage1-300x239.jpg" alt="UI Dialog: Original" width="300" height="239" /></p>
<p>This screenshot is actually from the realtime Icefall prototype. I needed a quick way to change screen resolutions for testing, so this is it. Some interesting features: The green background would slowly sway while the dialog was open, and there was a shimmering gold border around whichever element had keyboard focus.</p>
<h3>Revision</h3>
<p><img class="aligncenter size-medium wp-image-167" title="Icefall: Revision" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/11/Stage2-300x266.jpg" alt="Icefall: Revision" width="300" height="266" /></p>
<p>Fast forward to the turn-based rewrite of Icefall, and this is the original Video Options dialog. Some big changes: the background texture is more subdued, there is a panel on the left to select what <strong>type </strong>of options to view, and the gold-edge focus indicator has gone (now, the focused element is just highlighted a little more). Buttons and checkboxes have also had a minor makeover, e.g. the buttons are now rounded.</p>
<h3>Revision 2</h3>
<p><img class="aligncenter size-medium wp-image-168" title="UI Dialog: Revision 2" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/11/Stage3-300x248.jpg" alt="UI Dialog: Revision 2" width="300" height="248" /></p>
<p>What changed here? The window frame! Gone is the &#8216;rusted steel&#8217; frame from the top and bottom of the window, replaced with an ice-blue frame that encloses all four sides. I wanted to get more &#8220;ice theme&#8221; into the UI for the game, and at the same time I needed a UI frame that covered the left and right too, because not all UI elements use the slate background (the spellbook, for example, uses a &#8216;book&#8217; background, and it looked a little strange with no enclosing frame). I also think this looks better than the previous one.</p>
<h3>Current Design</h3>
<p><img class="aligncenter size-medium wp-image-169" title="UI Design: Final" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/11/Stage4-300x248.jpg" alt="UI Design: Final" width="300" height="248" /></p>
<p>Good, the rate-of-change of the dialog is slowing down, which means we&#8217;re getting closer to completion! The only change here is to the background of the listbox. The &#8216;green waves&#8217; looked ok in the original version, but as the look and feel of the rest of the dialog evolved, it began to look more and more out of place. When the dialog frames turned ice-blue, it was a good opportunity to build on that existing colourspace and again lend more of an &#8216;icey&#8217; theme to things by using a dark, ice-blue texture. This is what this dialog looks like in current builds. Hopefully, you agree with me that it&#8217;s the best looking of them all?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/11/icefall-ui-evolution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More Textures than Memory</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/11/more-textures-than-memory/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/11/more-textures-than-memory/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 05:10:19 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Good coding guidelines]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Freepascal]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=155</guid>
		<description><![CDATA[Icefall uses literally dozens of textures&#8230; (and it will probably be &#8216;hundreds&#8217; by the time the game is completed).
Textures are used for everything, from the mouse cursor, menus, fonts, buttons, to the game world itself, spells/action icons, monsters, equipment&#8230; everything.
Although my own main PC has 512MB of video (texture) RAM, not everyone does! And
following on [...]]]></description>
			<content:encoded><![CDATA[<p>Icefall uses literally dozens of textures&#8230; (and it will probably be &#8216;hundreds&#8217; by the time the game is completed).</p>
<p>Textures are used for everything, from the mouse cursor, menus, fonts, buttons, to the game world itself, spells/action icons, monsters, equipment&#8230; everything.</p>
<p>Although my own main PC has 512MB of video (texture) RAM, not everyone does! And<br />
following on from my <a href="http://www.paradicesoftware.com/blog/index.php/2009/11/minimum-requirements/">minimum requirements</a> post, I don&#8217;t really want someone&#8217;s video card memory size to be a limiting factor if everything else meets the requirements, so Icefall needs a way to manage things when there are more textures than there is video memory.</p>
<p>I don&#8217;t want each bit of code that uses textures to worry about whether they&#8217;re loaded or not, so the logical choice is to encapsulate all of the texture handling into one place: I call the class that handles this the <em>TContentManager</em> (&#8221;content&#8221; because it also handles sounds, fonts, music, etc.).</p>
<p>When the game code asks the <em>TContentManager</em> for a texture: the first thing it does is look to see if that texture is already available in video memory: if so, it just hands out a reference. Easy! If not, it retrieves the filename for that texture from Icefall&#8217;s <em>ResourceDatabase</em>, and attempts to load the texture from disk. If that fails, it looks at <strong>why</strong> it failed: if it&#8217;s <em>D3DERR_OUTOFVIDEOMEMORY</em>, the next step is to unload some other texture and try again, repeating until the load succeeds or we have no loaded textures left. (If it still doesn&#8217;t load, or if the texture load fails for some other reason, it&#8217;s goodbye Icefall).</p>
<p>Programmatically:</p>
<blockquote><pre>
function TContentManager.GetTexture(ID: TTextureID): TLXTexture;
var
   HRes: HRESULT;
   NewTexture: TLXTexture;
   FileName: String;
begin
   if TextureLoaded(ID) then
      exit(Texture[ID]);

   FileName := ResourceManager.Textures[ID].FileName;
   repeat
      HRes := LXLoadTexture(FileName,NewTexture);
      case HRes of
         D3D_OK:
            Texture[ID] := NewTexture;
         D3DERR_OUTOFVIDEOMEMORY:
            UnloadTexture(0);
      else
         // Fatal error!
      end;
   until TextureLoaded(ID);
   result := Texture[ID];
end function;
</pre>
</blockquote>
<p><em>UnloadTexture</em> is a method that unloads a texture. It takes a <em>TTextureID</em> as a parameter, but passing 0 in this case tells the method we want it to choose a texture to unload itself. This is where it gets interesting.</p>
<p>Before I got to this, I originally had set up a few states so that they explicitly called <em>TContentManager.UnloadTexture</em> to release textures when the game left that state (e.g. the game would unload the &#8216;Option-selection&#8217; texture when the player closed the Options dialog). However, this turned out to be sub-optimal for several reasons:</p>
<ul>
<li>Players might well leave and re-enter states (like Options) several times to accomplish whatever it is they&#8217;re trying to do.</li>
<li>It doesn&#8217;t make use of extra video memory: it keeps loading from disk (or the disk-cache anyway) while the extra video memory stays idle.</li>
<li>I had to explicitly declare what textures I was done with. Not a problem really but &#8216;just another thing&#8217; that I had to do when changing states.</li>
</ul>
<p>So now I no longer explicitly release anything. <em>UnloadTexture</em> always chooses the texture to unload that was least-recently used (a linked list makes this a very fast and efficient check &#8211; no timers or array scanning involved). In practise &#8220;least recently used&#8221; turns out to be about 97% optimal (when simulated against a 100% optimal algorithm which is permitted to see the future when deciding what to unload) so it&#8217;s virtually perfect &#8211; substantially better than my explicit declarations were. </p>
<p>If for some crazy reason the user doesn&#8217;t want Icefall consuming all of their video RAM*, I can chuck in a call to <em>IDirect3DDevice9.GetAvailableTextureMem</em> and trigger <em>UnloadTexture</em> if it&#8217;s below some specific amount. Alternatively, I could keep a sum of the amount of texture memory I&#8217;m using, and trigger <em>UnloadTexture</em> if that amount threatens to exceed 32MB or whatever (I haven&#8217;t decided yet).</p>
<p>The point is, if you find yourself manually balancing resources, it&#8217;s probably an excellent idea to profile your resource usage and see if you can find a pattern that will let you just automate the whole thing**. You&#8217;ll save yourself much time and your code will be cleaner and more flexible.</p>
<p>*Note: this only actually matters on Vista or Windows 7. Under the Windows XP model, multiple applications can&#8217;t share texture memory anyway. As soon as an application takes focus, DirectX invalidates all texture resources belonging to everything else (forcing them to reload from system-memory or disk when they get restored). The WDDM (Windows Display Driver Model) in Vista &#8220;understands&#8221; video memory, and can share it amongst applications. This is one of the reasons DirectX 10+ can&#8217;t be backported to XP: XP has no concept of video card resources.</p>
<p>**If you&#8217;re creating a game frame-rate locked or just frame-rate dependent, you might still need to explicitly acquire and release resources (e.g. between levels), because a 10ms pause at an unexpected point in your game could be noticeable or detrimental. Either that, or move the resource acquistion to another thread and have low-quality &#8216;emergency&#8217; textures to display while the real ones load&#8230; this is a very common technique for FPS games. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/11/more-textures-than-memory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minimum requirements</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/11/minimum-requirements/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/11/minimum-requirements/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 08:11:56 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Decision]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=114</guid>
		<description><![CDATA[What&#8217;s a reasonable minimum spec to aim for these days?
With Icefall, I&#8217;ve already taken the decision to target Direct3D9 &#8211; I get a lot of extra capabilities compared to DirectX8, and it still works with Windows XP unlike 10 or 11&#8230; a pretty simple decision.
But what about in terms of video memory? And system RAM? [...]]]></description>
			<content:encoded><![CDATA[<p>What&#8217;s a reasonable minimum spec to aim for these days?</p>
<p>With Icefall, I&#8217;ve already taken the decision to target Direct3D9 &#8211; I get a lot of extra capabilities compared to DirectX8, and it still works with Windows XP unlike 10 or 11&#8230; a pretty simple decision.</p>
<p>But what about in terms of video memory? And system RAM? What&#8217;s a realistic minimum these days? Icefall is a freeware, turn-based RPG, so by rights it shouldn&#8217;t require a leading edge PC, but I need a specific target to prevent limiting myself unnescessarily. </p>
<p>Howzabout 32mb video, and 512mb RAM? I think that fits most every PC you could buy in the last few years&#8230; and should be enough for some reasonable effects. Anyone got any thoughts on this?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/11/minimum-requirements/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>To install or not to install?</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/11/to-install-or-not-to-install/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/11/to-install-or-not-to-install/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 04:55:32 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[DirectX]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=102</guid>
		<description><![CDATA[Should Icefall come with an Installer/Setup program?
My previous games (like the Five Hundred card game) didn&#8217;t require any installation at all: it assumed you had DirectX7 (the game just failed if you didn&#8217;t), and all of the files it needed were in the same directory as the EXE itself. You just unzipped it to wherever [...]]]></description>
			<content:encoded><![CDATA[<p>Should Icefall come with an Installer/Setup program?</p>
<p>My previous games (like the Five Hundred card game) didn&#8217;t require any installation at all: it assumed you had DirectX7 (the game just failed if you didn&#8217;t), and all of the files it needed were in the same directory as the EXE itself. You just unzipped it to wherever you liked, and double clicked the EXE to play. To uninstall, you just delete the folder.</p>
<p>Icefall is a little bit more complicated. All of the game&#8217;s data is still a relative path from the EXE itself, but this time it needs a specific Direct3D9 library installed (one that doesn&#8217;t ship by default with the rest of DirectX, but that other games may have already installed). So I need to include the DX Installer. </p>
<p>The Microsoft DX installer is smart enough to not overwrite a newer version of the same library (and you can only include the needed library &#8211; I don&#8217;t have to include the full DX9 100mb installer!), so I don&#8217;t need to worry about that stuff, but the question is, should I include this as an &#8216;optional&#8217; installer that the user can run if Icefall doesn&#8217;t run immediately, or would it be less confusing to just make a full install program that all users run, and call this as a part of it (I could throw out options for the Start Menu etc. at the same time).</p>
<p>I&#8217;m leaning towards making a full installer, mainly because the DirectX library is designed to never be uninstalled (it&#8217;s a shared library, and other D3D9 apps might use it), and it would be very confusing for users to have an installer with no corresponding uninstaller&#8230; also, I may as well get with the program and use the Start Menu, registry etc. the way Windows programs are supposed to. Does anyone have any opinions on this?</p>
<p>Bonus trivia: I get quite regular emails about my Five Hundred game, since it made it onto lots of the large &#8216;freeware games&#8217; websites and was quite well received at the time. One of the common questions people ask these days is &#8220;how do I uninstall it? It&#8217;s not in Add/Remove programs&#8221;. They must have forgotten that they never installed it in the first place, just unzipped. A few of them are still confused when I tell them to just delete it, so it&#8217;s clearly not what today&#8217;s users are expecting.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/11/to-install-or-not-to-install/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Controlling Gamestate</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/controlling-gamestate/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/controlling-gamestate/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 18:57:41 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Gamestate]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=90</guid>
		<description><![CDATA[Virtually all programs have this, a central &#8216;game&#8217; loop that grabs user input, updates game logic, redraws the screen. At it&#8217;s simplest possible level, it usually looks something like this:

repeat
   Input;
   Update;
   Redraw;
until Quit;

The problem mainly comes in that middle section, Update. For any game, there are a variety [...]]]></description>
			<content:encoded><![CDATA[<p>Virtually all programs have this, a central &#8216;game&#8217; loop that grabs user input, updates game logic, redraws the screen. At it&#8217;s simplest possible level, it usually looks something like this:</p>
<blockquote>
<pre>repeat
   Input;
   Update;
   Redraw;
until Quit;</pre>
</blockquote>
<p>The problem mainly comes in that middle section, <em>Update</em>. For any game, there are a variety of different states you can be in (main menu, options screen, credits, playing game) and for most games, &#8220;playing game&#8221; breaks down into a whole lot more states by itself. For my simple 500 Card Game, I had states &#8220;bidding&#8221;, &#8220;dealing&#8221;, &#8220;choosing kitty&#8221;, as well as playing. If you&#8217;re not careful, your <em>Update</em> procedure can end up looking like this:</p>
<blockquote>
<pre>Procedure Update;
begin
   case State of
      STATE_MENU:
         // wait for a menu click
      STATE_OPTIONS:
         // handle user input
      STATE_CREDITS:
         // roll some credits
      STATE_GAME:
         case GameState of
            GS_PLAYING:
               // handle user input
               // update some monsters
            // etc
         end;
      // STATE_ even more stuff:
   end;
end;</pre>
</blockquote>
<p>So far, so big and clunky. It gets worse when you have to handle nested state transitions: in my card game, someone could be playing, then go to the Menu and come back. So I had to have a variable &#8216;LastState&#8217; that remembered where they were, so they could go back to it. But it&#8217;s worse than that, because they might go to the Menu, then go to the Options screen: and when they came back, they&#8217;d still want their current game to not be lost! My card game was simple, so I managed this as simply as I could: when entering the &#8216;menu&#8217; state, the menu grabbed it&#8217;s own copy of LastState, and it restored this value when the other screens (Options, Credits etc) returned to it, so there was always a way back to the game. This was the simplest case, because every state had exactly one other state that it could be transitioned from (you couldn&#8217;t get to Options from Game without going through Menu).</p>
<p>For Icefall though, the stakes were raised. I wanted the Options screen accessible from in-game, as well as in the initial menu. And there are many more states that the game can be in, and some of them should not be returned to (e.g the &#8220;create character&#8221; screen), so rather than a gigantic and ugly Update loop, I went back to good old OOP and implemented a class-based state stack.</p>
<p>Icefall has a central &#8220;State Engine&#8221; that looks after the current state stack, handles transitions between them, and calls whichever state is &#8216;on top&#8217; during the main loop. The State class looks something like this:</p>
<blockquote>
<pre>TIceState = class (TIceClass)
   constructor Create
      (StateEngine: TIceStateEngine;
       Transition: TStateTransition);
   procedure OnEnter; virtual;
   procedure OnLeave; virtual;
   procedure Update; virtual;
   procedure Redraw;
   // other useful state methods
   destructor Destroy; override;
end;</pre>
</blockquote>
<p>Essentially, for every state the game can be in, I have a corresponding class that defines it&#8217;s specific behaviour in <em>Update</em>. I can also do other &#8216;maintenence&#8217; (e.g. ensure the right music is playing) by overriding the OnEnter and OnLeave procedures. The game can change states by constructing a new <em>TIceState</em> instance, passing it a reference to the state engine and describing the type of transition to use (e.g. whether to nest the state [for a trip to a Menu] or just progress to the new state with no way back [like a character create screen]). You can also leave a state just by destructing the class instance: the state engine will pop back to the next highest state on the state stack, or quit the game if there are no states left (e.g., you just hit &#8216;Exit&#8217; from the Main Menu). </p>
<p>The state engine takes care of nested states and transitions, and someone&#8217;s <strong>exact</strong> state in the game can be saved (if needed) by storing the entire state stack: while I&#8217;m unlikely to want the game to be saved while on the Character Create screen, it&#8217;s good to know I can safely save the game while in shops, or at any other point, without even worrying about special handling code to cover all the situations.</p>
<p>Another interesting thing I have done is move the game&#8217;s &#8220;loader&#8221; (the part that loads textures, sounds, music, fonts, databases) into it&#8217;s own state, and just made it the very first state that&#8217;s pushed onto the stack, and it takes a parameter to the state to transition to when it&#8217;s done. It takes the whole &#8216;loading&#8217; step out of the main game code, which makes that much simpler, and I can make the loader just load the resources I&#8217;m going to need right now: some other state (like the credits) can always call it again later to load specific credit-y images.</p>
<p>I can also use the the same game engine to build other tools like the Map Editor: the only difference between the map editor and the game itself is that it compiles in a different set of states: when the map editor has loaded, it launches itself into a <em>TMapEditorState</em> instead of a <em>TMainMenuState</em>.</p>
<p>Overall, having a <strong>state stack</strong> is very flexible, quite simple to use and maintain, and overall a vast improvement from the &#8216;giant case statement&#8217; I was using previously.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/controlling-gamestate/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OOP Part 3: Composition</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-3-composition/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-3-composition/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 06:05:18 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=80</guid>
		<description><![CDATA[Last time, we looked at the inheritance style of object-oriented programming in detail. Now let&#8217;s look at the alternative: composition.
We&#8217;ll use another example from Icefall to illustrate the differences. Icefall has a central &#8216;world view&#8217; that shows the player and their immediate surroundings (items, monsters, terrain, etc). The world view also shows animations (e.g. fireballs, [...]]]></description>
			<content:encoded><![CDATA[<p>Last time, we looked at the <strong>inheritance</strong> style of object-oriented programming in detail. Now let&#8217;s look at the alternative: <strong>composition</strong>.</p>
<p>We&#8217;ll use another example from Icefall to illustrate the differences. Icefall has a central &#8216;world view&#8217; that shows the player and their immediate surroundings (items, monsters, terrain, etc). The world view also shows animations (e.g. fireballs, weapons swinging, speech bubbles, etc) and it&#8217;s the animation code that we&#8217;ll be looking at in detail today.</p>
<p>I designed this feature around each animation being a class instance, with the class methods and properties making it easy for the game engine to control the details (lifetime, location, save/load etc etc). I knew I&#8217;d have several different types of animation, so my initial implementation chucked all that &#8216;management&#8217; functionality into a <em>TAnimation</em> class, and left virtual methods for  things like <em>Process</em> and <em>Draw</em> for descendents to implement. After creating a few basic animations, my class hierarchy looked like this:</p>
<blockquote>
<pre>TAnimation
   TAnimText
      TAnimSpeech
      TAnimTexturedText
   TAnimTexture
      TAnimMissile
      TAnimExplosion
      TAnimMelee</pre>
</blockquote>
<p>Animations with text (i.e. picking up an item) were a subclass, and speech bubbles (or text with a textured background) were subclasses of that. Missiles (like fireballs) were a subclass where the animation moved from one place to another (and was rotated to face the right direction), and Explosions were in one place but had a series of animation frames over time. Melee animations showed a weapon and some motion-blur, sweeping out to attack a monster/player.</p>
<p>The problem with this system, which I discovered after adding <em>TAnimTexturedText</em> (specificially to show damage-dealt as a number on a bloodsplat-graphic background) was that most of the subtypes only varied in very small ways, and the overhead of naming, constructing and using each subtype took more effort than defining the subtype itself. Also, the &#8216;event&#8217; system I was setting up for Icefall was supposed to allow for animations to be defined dynamically in response to any spell or event (and new events added in data files without recompiling the game) &#8211; but the code that supported this was going to be very complex and ugly if it had to choose between all of the different constructors each time and pass a specific set of parameters to make it happen.</p>
<p>So, I rewrote the animation subsystem to bring any functionality that I could possibly re-use into the parent class: now, all animations had a <em>Texture</em> property, a <em>Rotate</em> property, <em>Frames</em>, <em>Movement</em>, <em>Sound</em>&#8230; which could all be left at Nil or 0 if not needed. My new, composited animation hierarchy looked like this:</p>
<blockquote>
<pre>TAnimation
   TAnimText
      TAnimSpeech</pre>
</blockquote>
<p>As soon as I did this, I found that it was not only easier to manage the sources, but that features of the parent class ended up getting used more often than I anticipated: e.g. giving an explosion a random value for <em>Rotate</em> made each explosion look slightly different, and I could apply a small <em>Movement</em> value to Text to let it &#8216;float&#8217; upwards from where it first appeared: new and useful functionality essentially for &#8216;free&#8217;.</p>
<p>Note that I kept <em>AnimText</em> separate from the parent, because there is some substantially different functionality: it has text (which directly contributes to the size and position of the anim), which is also dynamic, and there is some special logic to ensure two text animations don&#8217;t overlap each other. It made sense to move this code out into a specific class where it could be closely tweaked. Speech is different again, because there is a &#8220;speaker&#8221; creature that it it linked to: the speech bubble needs to move around with it&#8217;s speaker, disappear if they die, etc.</p>
<p>In summary, now that the <em>TAnimation</em> class is composited, it&#8217;s significantly &#8216;better&#8217; code than before:</p>
<ul>
<li>Fewer types to worry about</li>
<li>Much easier to follow the logic of the code in a single class</li>
<li>Can trivially re-use functionality developed for one subtype in others</li>
<li>Much easier for other code to utilise this class effectively</li>
</ul>
<p>So, my conclusion in this small series is:</p>
<p>Use composition in your classes, unless there is substantially different behaviour, or external code needs to interact with a specific subtype in a special way (e.g. <em>TAnimation</em> itself is inherited from <em>TWorldObject</em>, because the world view needs to interact with animations in a specific way).</p>
<p>Next time, I&#8217;ll find something different to ramble on about.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-3-composition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OOP Part 2: Inheritance</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-2-inheritance/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-2-inheritance/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 07:00:37 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Freepascal]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=64</guid>
		<description><![CDATA[Last time, we talked about two different approaches to designing objects for a game or application: Inheritance and Composition. It&#8217;s time to look at the pros and cons in more detail. Let&#8217;s start with inheritance.
Inheritance
When learning OOP, inheritance is what you learn! Create a common, generic ancestor-type class, and create new classes for specific game [...]]]></description>
			<content:encoded><![CDATA[<p>Last time, we talked about two different approaches to designing objects for a game or application: Inheritance and Composition. It&#8217;s time to look at the pros and cons in more detail. Let&#8217;s start with inheritance.</p>
<h3>Inheritance</h3>
<p>When learning OOP, inheritance is what you learn! Create a common, generic ancestor-type class, and create new classes for specific game objects which inherit from, override and extend the functions of the ancestor. Repeat as desired. Let&#8217;s look at the consequences of following this model:</p>
<p>Pros:</p>
<ol>
<li>It&#8217;s easy to locate all functionality belonging to each type: they&#8217;re together in the source for the child class.</li>
<li>It&#8217;s easy to write an appropriate constructor for the type; so you know the classes internal state will be consistent.</li>
<li>It&#8217;s easy to guard against the wrong type being passed to a function at compile time: If you have <em>Function AttackMonster(WithWeapon: TWeapon);</em> the compiler will prevent you passing a <em>TItem</em> that isn&#8217;t a <em>TWeapon</em>.</li>
<li>You can specify abstract methods in the parent where you know the divergent behaviour will be, and the language and compiler will help you get there and warn you if you&#8217;ve left something out.</li>
</ol>
<p>Cons:</p>
<ol>
<li>You end up with *lots* of different classes &#8211; which may be in lots of different files.</li>
<li>Some of the classes can be really, really small&#8230; e.g., a single method override.</li>
<li>When looking at the child class implementation with a call to the inherited parent, you don&#8217;t know exactly what the parent does.</li>
<li>If two different children of a common ancestor need the same functionality, you have to code it twice.</li>
<li>Code that constructs instances must take care to call the correct constructor.</li>
<li>You can&#8217;t &#8220;switch&#8221; a child to a different type; you need to destruct it and create a new instance of the other type.</li>
<li>Greater risk of circular-references if your child classes need to interact with each other.</li>
</ol>
<p>You can see the pattern forming. The <strong>Pros</strong> of this model tend to be that things are easier to setup up-front, when you&#8217;re initially coding the classes. The <strong>Cons</strong> tend to hit you later: when you&#8217;re extending functionality, or just coming back to the code after time spent elsewhere.</p>
<p>It&#8217;s also possible with this model to really make life impossible for yourself. If you come up against Con #4 and are tempted to move some of that common functionality in the parent class, congratulations: you just blasted Pro #1 and debugging and maintaining this code just became a nightmare, and now the parent needs to duplicate some child state in order to know which of these &#8220;optional-children&#8221; operations it should perform. Ick!</p>
<p>Note that this inheritance style is still arguably a gigantic code-safety and readibility improvement from old-style procedual code. The question is, can we do better? In Part 3, we&#8217;ll look at the alternative model of Composited classes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/oop-part-2-inheritance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows 7 compatibility</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/windows-7-compatibility/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/windows-7-compatibility/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 08:35:51 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Amusing]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=59</guid>
		<description><![CDATA[I&#8217;m working on the follow up to my Object-Oriented Programming post, but in the meantime I had to share this:
I tested Icefall on Windows 7 for the first time today (having developed &#38; tested exclusively on Windows XP SP 3 up until now). It worked perfectly, in fact it ran a little more smoothly than [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on the follow up to my Object-Oriented Programming post, but in the meantime I had to share this:</p>
<p>I tested Icefall on Windows 7 for the first time today (having developed &amp; tested exclusively on Windows XP SP 3 up until now). It worked perfectly, in fact it ran a little more smoothly than it does on the same computer on XP.</p>
<p>It&#8217;s always reassuring when your application turns out to be forward-compatible, it&#8217;s a good sign my low-level code isn&#8217;t performing any horrendous unsupported operations, <a href="http://weblogs.asp.net/rosherove/archive/2004/06/18/158620.aspx">SimCity-style</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/windows-7-compatibility/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Object-oriented programming</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/object-oriented-programming/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/object-oriented-programming/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 22:21:28 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Freepascal]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=40</guid>
		<description><![CDATA[Like almost everything else these days, Icefall is designed around object-oriented programming (OOP) principles. Specifically, Icefall uses Classes instead of objects, although the difference is not relevant for this discussion.
At any given time, the game will be operating dozens of different classes and hundreds of instances of those classes, with the majority of them representing [...]]]></description>
			<content:encoded><![CDATA[<p>Like almost everything else these days, Icefall is designed around object-oriented programming (OOP) principles. Specifically, Icefall uses Classes instead of objects, although the <a title="Freepascal: Classes" href="http://www.freepascal.org/docs-html/ref/refch6.html" target="_blank">difference</a> is not relevant for this discussion.</p>
<p>At any given time, the game will be operating dozens of different classes and hundreds of instances of those classes, with the majority of them representing either individual game objects (an item, a monster, the player) or a piece of the user interface (a button, an animation, etc). As you&#8217;d expect, many of these classes inherit from other classes (e.g. the button class is inherited from the generic UI class) but the question of exactly how much inheritance to use is something that confuses many people &#8211; and if you get it wrong, your code will suffer. So let&#8217;s take a closer look.</p>
<h3>Inheritance vs Composition</h3>
<p>Turning a program&#8217;s logic into a group of classes seems easy (hmm, my game has items, let&#8217;s make a <em>TItem</em> class!), but choosing the right combination of classes is harder than it looks. Like everything else, the more complex your application is, the harder and more important these choices will be.</p>
<p>One common choice is to do everything via inheritance. You make some ancestor classes which contain <strong>only</strong> the logic that will be common to all descendents, and you create inherited classes to cover all exceptions or additions to that logic. This style is called<em><strong> </strong></em><strong>inheritance</strong> for obvious reasons, and lots of newcomers to OOP start like this. Let&#8217;s create an example that shows this in action:</p>
<p>Icefall needs to know an item&#8217;s worth (in gold) to a shopkeeper to allow the player to buy/sell it. As items in Icefall can have randomly generated properties, we can&#8217;t define the worth of everything at compile time (and even if we could, there will be hundreds of different items in Icefall. Don&#8217;t specify things you could calculate. I&#8217;ll talk about this another time). So we need a method in the <em>TItem</em> class to calculate the item&#8217;s worth for us.</p>
<h3>Inheritance</h3>
<p>The inheritance solution might look like like this:</p>
<blockquote>
<pre>TItem = class
   function Worth: Integer; virtual;
end;

function TItem.Worth: Integer;
begin
   result := ILevel * 20; // ILevel is another property.
end;</pre>
</blockquote>
<p>Nice and easy so far. The item&#8217;s worth is calculated as being 20 times it&#8217;s <em>ILevel</em> (item-level). But what happens when we want to make some items (let&#8217;s say weapons) more valuable than others? The inheritance solution is to build on the existing code and do this:</p>
<blockquote>
<pre>TWeapon = class (TItem)
   function Worth: Integer; override;
end;

function TWeapon.Worth: Integer;
begin
   result := 100 + ILevel * 50; // Weapons are worth more
end;</pre>
</blockquote>
<p>We have overridden <em>TItem</em>&#8217;s <em>Worth</em> function with a new one just for <em>TWeapon</em>. We just have to remember that when we&#8217;re creating items, if it&#8217;s a weapon we need to construct a <em>TWeapon</em> class instead of a <em>TItem</em> class to hold it, and the right <em>Worth</em> function will be called automatically.</p>
<h3>Composition</h3>
<p>Meanwhile, another style, often referred to as <strong>composition</strong>, says to group similar functionality together, and use members or properties to determine the appropriate behaviour for each instance:</p>
<blockquote>
<pre>TItemType = (ITEMTYPE_NORMAL,ITEMTYPE_WEAPON);

TItem = class
   function Worth: Integer;
   property ItemType: TItemType;
end;

function TItem.Worth: Integer;
begin
   case ItemType of
      ITEMTYPE_WEAPON :
         result := 100 + ILevel * 50;
   else
      result := ILevel * 20;
   end;
end;</pre>
</blockquote>
<p>Already, for our tiny example, the two implementations are looking considerably different. The composited version defines a class property called <em>ItemType</em> that stores what type of item this instance represents, and the <em>Worth</em> function contains all the functionality for both item types (I used a <em>case</em> statement instead of a simple <em>if</em>, because I suspect I will end up with more than two item types).</p>
<p>p.s. Icefall, of course, takes much more into account to determine an item&#8217;s worth: it&#8217;s rarity, any enchantments, whether the shopkeeper likes the player, etc etc. But that wasn&#8217;t relevant for this discussion <img src='http://www.paradicesoftware.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h3>Conclusion</h3>
<p>So which is better? What are the pros and cons of each style? Tune in next time to find out!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/object-oriented-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Real-time, or turn-based?</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/real-time-or-turn-based/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/real-time-or-turn-based/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 22:18:00 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Decision]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=26</guid>
		<description><![CDATA[The next step in Icefall&#8217;s development was to decide whether to make the game realtime (like Diablo, Titan Quest, World of Warcraft&#8230;) or turn-based (Angband, Nethack, Ultima 1..5). This is probably the biggest decision for a role-playing game, as it dictates the entire gameplay, as well as the UI, multiplayer, everything.
Initially, I looked at real-time. [...]]]></description>
			<content:encoded><![CDATA[<p>The next step in Icefall&#8217;s development was to decide whether to make the game realtime (like Diablo, Titan Quest, World of Warcraft&#8230;) or turn-based (Angband, Nethack, Ultima 1..5). This is probably the biggest decision for a role-playing game, as it dictates the entire gameplay, as well as the UI, multiplayer, everything.</p>
<p>Initially, I looked at real-time. This is the only choice for multiplayer (turn-based multiplayer just doesn&#8217;t flow) and all of the &#8216;modern&#8217; games follow this formula. So I developed a playable prototype along these lines. While still using a tile-based world, this would allow freeform movement (characters were not tied to specific &#8217;tile&#8217; locations), and could have supported multiplayer quite naturally. Using placeholder graphics borrowed from games, I developed a prototype game that ran in real-time:</p>
<div id="attachment_27" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/10/Icefall_prototype.jpg"><img class="size-medium wp-image-27 " title="Icefall_prototype" src="http://www.paradicesoftware.com/blog/wp-content/uploads/2009/10/Icefall_prototype-300x235.jpg" alt="Prototype of Icefall in real-time" width="300" height="235" /></a><p class="wp-caption-text">Prototype of Icefall in real-time</p></div>
<p style="text-align: left;">The prototype accomplished it&#8217;s goal, which was to determine whether real-time was feasible, and what the challenges would be. After getting the prototype running with some simple monsters, I had figured out the challenges I would be facing:</p>
<p style="text-align: left;">* Pathfinding dozens of monsters around a complex environment, in real time, is very hard.</p>
<p style="text-align: left;">* Real-time locks you into a specific travel speed, and can make &#8216;huge worlds&#8217; time consuming to explore.</p>
<p style="text-align: left;">* It was very hard to find the right &#8216;game speed&#8217;. Too slow and players get frustrated and bored. Too fast and the monsters can kill the player too quickly. I wanted players to dictate the pace: in Angband, you can play it very quickly or very slowly. I couldn&#8217;t find how to do that with real-time (a &#8220;game-speed&#8221; slider would not accomplish this).</p>
<p style="text-align: left;">* It just didn&#8217;t feel like the game I wanted to make. (I have played too much Angband).</p>
<p style="text-align: left;">* It didn&#8217;t quite &#8216;fit&#8217; with other concepts I had already thought about, as well. e.g. I already knew that I would be implementing a &#8216;monster memory&#8217;, which tracked monster kills for players and stored any weaknesses/vulnerabilities/etc the player observed. With a real-time game, I couldn&#8217;t figure out how the player would access the monster memory without pausing the game (which would be ugly for multiplayer) or just looking it up academically after the battle was already over (not very useful).</p>
<p style="text-align: left;">Making the decision to go turn-based was a big &#8216;constraint&#8217; in itself, but with the decision made, it makes many many other features much easier, and seems to make the player&#8217;s overall experience more relaxing.</p>
<p style="text-align: left;">This final key decision having been made, I was ready to start some actual coding. Next time, I think I&#8217;ll mix it up a bit by looking at an actual code sample&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/real-time-or-turn-based/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Icefall</title>
		<link>http://www.paradicesoftware.com/blog/index.php/2009/10/hello-world/</link>
		<comments>http://www.paradicesoftware.com/blog/index.php/2009/10/hello-world/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 08:21:40 +0000</pubDate>
		<dc:creator>Lawrence</dc:creator>
				<category><![CDATA[Icefall]]></category>
		<category><![CDATA[Decision]]></category>
		<category><![CDATA[Freepascal]]></category>

		<guid isPermaLink="false">http://www.paradicesoftware.com/blog/?p=1</guid>
		<description><![CDATA[I am currently working on a new role playing game called Icefall, and to help maintain clear thinking, correct decisions, etc etc etc, I&#8217;ve decided to document the development journey on this website as a blog. That way, once Icefall is released and becomes hugely popular (:D), I will have a solid record of how [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently working on a new role playing game called Icefall, and to help maintain clear thinking, correct decisions, etc etc etc, I&#8217;ve decided to document the development journey on this website as a blog. That way, once Icefall is released and becomes hugely popular (:D), I will have a solid record of how it happened. As the game is currently about 25% complete, it&#8217;s a good opportunity to summarise the progress to-date and take a look at the &#8216;big&#8217; decisions, which have already been made:</p>
<h3>Decision: Role Playing Game</h3>
<p>Many of the very first games I got hooked on were RPGs: Moria, Ultima 5, Death Knights of Krynn) but each of them always had things I thought &#8220;if only it did&#8230;&#8221;, so creating my own game would be my opportunity to put that into practice. I&#8217;ve started to create many RPGs over the years, but I&#8217;ve never finished one or even got it largely playable. This was due to various different causes, either I&#8217;d hit a wall somewhere (pathfinding, AI, memory, and graphical speed have all defeated me over the years) or a new game (Halo, World of Warcraft) would come along and I&#8217;d abandon my development for long enough that I forgot the intricate workings of the code, and rather than dive back in I abandoned it.</p>
<p>So I&#8217;ve still never made a role playing game. Time to fix this!</p>
<p>Another good reason is that it&#8217;s within my ability. Making something like a first-person shooter (at least, a good one!) just wouldn&#8217;t be possible for me because having decent graphics is too large a part, and my graphical ability&#8230; well, let&#8217;s just call it &#8220;<a href="http://www.paradicesoftware.com/gui/launch.htm?http://en.wikipedia.org/wiki/Programmer_art" target="_blank">Programmer Art</a>&#8221; and move on.</p>
<h3>Decision: Free Pascal</h3>
<p>Having decided on the type of game I&#8217;m making, the next step is to choose the programming language. These days there are more languages than ever, and some of the new ones are really good. C# + XNA would be my &#8216;high level&#8217; choice, it makes it ridiculously easy to get graphics on the screen and a game up and running&#8230;</p>
<p>But&#8230;</p>
<p>I&#8217;m not just programming to make a game, I&#8217;m also doing this because I want to be challenged. I want to take fundamental, low-level control over everything my code does in every situation. Using a low-level language (C++, Pascal&#8230;) means there&#8217;s a lot more up-front effort involved (getting graphics on the screen isn&#8217;t one line of code anymore, it&#8217;s a couple of hundred) but, to me, also much more satisfaction when it works!</p>
<p>When I want to add a function, I can&#8217;t just copy a C# code snippet from the internet, I&#8217;ve had to go away and install the DirectX SDK, read the documentation for each instruction, look at the example code, re-interpret it to suit what I&#8217;m trying to do, and play with it until I get it to compile. The reward (and the knowledge that is acquired as a consequence of having to research every call) is worth it. (This is the same reason I&#8217;m not using an existing &#8216;game engine&#8217;, I&#8217;m creating my own with LX7).</p>
<p>Having decided to use a low-level language, my choices are C++ and Pascal (I don&#8217;t want to learn another language at the same time as creating a complex game, the game at the end would suffer too much as a result of my learning-while-doing). I chose Pascal because, I&#8217;m not really sure why, I just &#8220;like it&#8221;.It has all the language constructs I&#8217;m going to need (primarily Classes), and I like that it&#8217;s not quite as low-level as C++, which gives me a little bit more room to spend on game logic but without having to sacrifice anything.</p>
<p>Finally, choosing between my Pascal options, FreePascal and Delphi&#8230; I think FreePascal is superior! It definately compiles faster and makes smaller executables. It doesn&#8217;t support Windows GUI very well, but Icefall like 99% of games will have custom UI anyway. It&#8217;s also free. Finally, the platform is far less common than C++, and there aren&#8217;t many games in development using it (especially on Windows), so when the game is done and LX7 (the graphics/game engine I&#8217;m creating to support Icefall at the same time) is finished, I might have something to give back to the FreePascal community. So it&#8217;s settled!</p>
<p>Next time, I will talk about the third key decision for Icefall: whether to make it real-time, or turn-based?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.paradicesoftware.com/blog/index.php/2009/10/hello-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
