<?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>Dr Nic &#187; CSS</title>
	<atom:link href="http://drnicwilliams.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Mon, 15 Mar 2010 20:51:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>[BTS] Dr Nic&#8217;s Civilizations 2.0</title>
		<link>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/</link>
		<comments>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/#comments</comments>
		<pubDate>Thu, 24 Aug 2006 22:32:43 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[BTS]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Preview]]></category>
		<category><![CDATA[Trick]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/</guid>
		<description><![CDATA[I&#8217;m not promising there ever will be a Dr Nic&#8217;s Online Civilizations game, but it has seemed like a good idea for a few weeks, and today I went from ASCII map through to beautiful CSS rendering of the map.


6amASCII to HTML mapping
8amBase tiles
6pmCorrect edges
9pmConvert table to div structure








I miss home.
This was a technically interesting [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not promising there ever will be a Dr Nic&#8217;s Online Civilizations game, but it has seemed like a good idea for a few weeks, and today I went from ASCII map through to beautiful CSS rendering of the map.</p>
<table border=0>
<tr align=center>
<th>6am<br />ASCII to HTML mapping</th>
<th>8am<br />Base tiles</th>
<th>6pm<br />Correct edges</th>
<th>9pm<br />Convert table to div structure</th>
</tr>
<tr align=center>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-01-map-to-colour-scheme.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-01-map-to-colour-scheme.thumbnail.png" alt="Simple layout of map" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-02-basic-tiles.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-02-basic-tiles.thumbnail.png" alt="Basic tiles" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-04-tile-variations-correct-edges.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-04-tile-variations-correct-edges.thumbnail.png" alt="Correct edges" /></a></td>
<td><a class=thickbox href="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-06-removed-table.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/20060827-06-removed-table.thumbnail.png" alt="Removed table structure" /></a></td>
</tr>
</table>
<p>I miss home.</p>
<div><a style="float: right" href="http://drnicwilliams.com/wp-content/uploads/2006/08/tiles.png"><img border=0 src="http://drnicwilliams.com/wp-content/uploads/2006/08/tiles.thumbnail.png" alt="Tilesheet" /></a>This was a technically interesting process. The images used are actually all on the one base tile sheet <a href="#a1">[1]</a>, and each panel of the map is allocated a separate CSS class relating to the specific tile required.</div>
<p>So for example, to show the base grasslands tile, you&#8217;d need some CSS like:</p>
<pre>
.tiles {height: 30px; width: 30px; background: url(tiles.png) top left no-repeat; ...}
.grasslands {background-position: 0px -30px;}</pre>
<p>For a desert tile, with some grasslands to the left, you might use:</p>
<pre>
.desert-left {background-position: -60px -60px;}</pre>
<p>This really gives a nice tiling effect without you needing to do any fancy image manipulations or the user loading up lots of small images. You just assign the appropriate CSS class to the panel (a DIV or TD, for example). Want to change a tile? Change the class (e.g. using Prototype/jQuery libraries)</p>
<p>Yes, this solution requires lots of individual CSS class definitions; but you&#8217;re clever &#8211; you&#8217;ll generate them won&#8217;t you <img src='http://drnicwilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h3>Reader assistance required</h3>
<p>The one technical trick that I don&#8217;t have a solution for at the moment is a Google Maps-like interface for scrolling map around. I&#8217;d love to hear from anyone with some bright thoughts on how they implement that (I don&#8217;t want to have to try to read their compact Javascript code).</p>
<p>Any thoughts?</p>
<p><a name="a1">[1]</a> The source images came from the <a href="http://www.freeciv.org/index.php/Freeciv">FreeCiv</a> GPL game</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2006/09/07/turn-based-game-dsl/' rel='bookmark' title='Permanent Link: Turn-based game DSL'>Turn-based game DSL</a> <small>Late in the night, whilst the baby feeds, I continue...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2006/08/25/bts-dr-nics-civilizations-20/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
