<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Matt Pearce&#039;s Blog</title>
	<atom:link href="http://matp.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://matp.wordpress.com</link>
	<description>C++/Objective-C Game Development Articles</description>
	<lastBuildDate>Mon, 05 Apr 2010 13:25:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='matp.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Matt Pearce&#039;s Blog</title>
		<link>http://matp.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://matp.wordpress.com/osd.xml" title="Matt Pearce&#039;s Blog" />
	<atom:link rel='hub' href='http://matp.wordpress.com/?pushpress=hub'/>
		<item>
		<title>iPhone Development: Generating 2D collision maps for textures</title>
		<link>http://matp.wordpress.com/2010/04/05/iphone-development-generating-2d-collision-maps-for-textures/</link>
		<comments>http://matp.wordpress.com/2010/04/05/iphone-development-generating-2d-collision-maps-for-textures/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 13:24:35 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[iPhone Development]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://matp.wordpress.com/?p=28</guid>
		<description><![CDATA[I thought it would be a good idea to go over some of the details of generating collision maps on the iPhone, as the situation can be a bit unclear unless you understand just how the PowerVR hardware handles the various texture formats. Note that an alternative option to generating collision maps at runtime is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=28&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I thought it would be a good idea to go over some of the details of generating collision maps on the iPhone, as the situation can be a bit unclear unless you understand just how the PowerVR hardware handles the various texture formats.<span id="more-28"></span></p>
<p>Note that an alternative option to generating collision maps at runtime is to precalculate them and load them in. This would allow you to be more specific with the regions you wish to collide (i.e. you could edit the collision map after generating it). If you are simply going to use the alpha data as the collision data, however, storing it twice is a waste of space (not much space, but space nonetheless!) Also, I assume that the file format being used is the PowerVR format.</p>
<p>When encoding textures in the .pvr format, you have two options. The first is to use a standard format (ARGB8888, ARGB1555, etc) and the second is to use a compressed PowerVR format (PVR2bpp/PVR4bpp). The basic idea of generating a collision map is to alter the PowerVR texture loading code to grab a copy of the alpha channel, determine visible regions, and store a copy of this data for use as collision data.</p>
<p>As long as you are using an uncompressed format, this process is quite straightforward. Where you need to be aware of potential difficulties is when dealing with the compressed formats. The issue here is the fact that the PowerVR chipset in the iPhone supports these compression formats natively. When loading the textures, the SDK code checks for compressed textures support (which it finds in the case of the iPhone), and then simply loads the compressed textures into memory.</p>
<p>Because the texture is never decompressed, you can not simply access the alpha channel. The only option in this case is to separately decompress the texture and then generate the collision data. The decompression process is quite slow, however, so decompressing the texture should be avoided whenever possible.</p>
<p>My recommendations are:</p>
<ol>
<li>Use only uncompressed formats when it is necessary to generate collision data from the texture.</li>
<li>If you must use compressed formats for these textures, precalculate the collision data.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matp.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matp.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matp.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=28&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matp.wordpress.com/2010/04/05/iphone-development-generating-2d-collision-maps-for-textures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04f4ef45114fb14018fddbda96c231fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
		<item>
		<title>Stratum Engine: Explaining the event handler syntax</title>
		<link>http://matp.wordpress.com/2010/04/04/stratum-engine-explaining-the-event-handler-syntax/</link>
		<comments>http://matp.wordpress.com/2010/04/04/stratum-engine-explaining-the-event-handler-syntax/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 11:02:19 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Stratum Engine]]></category>
		<category><![CDATA[Stratum]]></category>

		<guid isPermaLink="false">http://matp.wordpress.com/?p=18</guid>
		<description><![CDATA[As I mentioned in the previous post, the engine uses a somewhat unconventional syntax for defining event handlers: As you may have guessed (and good on you if you did!), this is a preprocessor macro that expands to something like this: The reason I implemented the event handler syntax like this is the structure of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=18&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in the previous post, the engine uses a somewhat unconventional syntax for defining event handlers:</p>
<p><pre class="brush: cpp;">

void EVENT_onClick
{
   // ...
}

</pre><br />
<span id="more-18"></span><br />
As you may have guessed (and good on you if you did!), this is a preprocessor macro that expands to something like this:</p>
<p><pre class="brush: cpp;">

void onClick(float _fX, float _fY)
{
   // ...
}

</pre></p>
<p>The reason I implemented the event handler syntax like this is the structure of the engine. Unlike some event-oriented systems, the Stratum Engine does not require event handlers to be registered before receiving events. This is due to the layering system I have used &#8211; each event is handled by each layer in order of where the layer is in the stack. This is implemented by having a parent class from which all layers derive, and the base class having blank functions to handle each event. If a layer wishes to respond to an event, it overrides the corresponding function.</p>
<p>This is the first reason that macros are used &#8211; if any error is made in the function signature when creating a new layer class, the program will compile and run perfectly, but the handler will never be called. This can lead to difficult-to-diagnose errors. By using macros, the compiler will display an error if a mistake is made in the macro name.</p>
<p>The second reason is that the arguments passed to a function may change in the future. It would be a large refactoring effort to ensure that all derived layers have the function signatures updated to reflect the altered arguments. Additionally, any errors or missed classes when updating the functions would again result in the handler not being called. The benefit here is that simply updating the macro will result in all classes using it being automatically updated as well.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matp.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matp.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matp.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=18&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matp.wordpress.com/2010/04/04/stratum-engine-explaining-the-event-handler-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04f4ef45114fb14018fddbda96c231fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
		<item>
		<title>Stratum Engine introduction</title>
		<link>http://matp.wordpress.com/2010/04/03/stratum-engine-introduction/</link>
		<comments>http://matp.wordpress.com/2010/04/03/stratum-engine-introduction/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 11:07:48 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Stratum Engine]]></category>
		<category><![CDATA[Stratum]]></category>

		<guid isPermaLink="false">http://matp.wordpress.com/?p=7</guid>
		<description><![CDATA[I would like to begin by introducing the engine I developed for our iPhone games. Firstly, here is a short feature list: Optimised for quick prototyping (shortest amount of code possible to get to a playable game) Pure C++ with a few Objective-C delegates to manage interaction with the iPhone OS Uses a stack-based state [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=7&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I would like to begin by introducing the engine I developed for our iPhone games. Firstly, here is a short feature list:</p>
<ul>
<li>Optimised for quick prototyping (shortest amount of code possible to get to a playable game)</li>
<li>Pure C++ with a few Objective-C delegates to manage interaction with the iPhone OS</li>
<li>Uses a stack-based state machine architecture</li>
<li>Supports all iPhone input features</li>
<li>Gesture recognition (similar to &#8220;$1 Unistroke Recognizer&#8221;¹)</li>
<li>Hardware accelerated sprite engine</li>
</ul>
<p>Each state of the game is defined within a <em>layer</em>. These layers can be pushed onto or popped from a central <em>stack</em>. <span id="more-7"></span>The granularity of states represented by the layers depends largely on the type of game being represented. To give you an example, a set of layers for a simple puzzle game could be:</p>
<blockquote><p>Main Menu</p>
<p>Game</p>
<p>Pause Menu</p>
<p>Credits</p>
<p>etc.</p></blockquote>
<p>Alternatively, an RPG may have layers such as:</p>
<blockquote><p>Main Menu</p>
<p>Overworld</p>
<p>Town</p>
<p>Battle</p>
<p>Inventory</p>
<p>Dialogue</p>
<p>etc.</p></blockquote>
<p>Each of these layers receive and may respond to a number of events. It is not necessary to subscribe to events in order to receive them. Each layer is derived from a parent class, and simply implements event handlers for each event it wishes to respond to. Most events are handled by each layer on the stack, in order from top to bottom. The exception is the Draw event, which must necessarily be handled from bottom to top.</p>
<p>Each layer also has a filter that defines which events should not be passed on to lower layers. A typical filter for a Pause screen would be:</p>
<blockquote><p>Event::All ^ Event::Render</p></blockquote>
<p>This means that all events except the render event will be blocked (since input and update events are blocked, the lower layers are therefore automatically &#8220;paused&#8221;.</p>
<p>I will have more articles coming soon, but for now, here is a complete implementation of the aforementioned Pause screen:</p>
<p><pre class="brush: cpp;">
class Pause : public ILayer
{
public:
   LAYER_FILTER(Event::All ^ Event::Render);

   // Called when the layer is added to the stack
   void EVENT_onAdd
   {
      m_sprBackground.Load(&quot;Backgrounds/Paused&quot;);
      m_sprBackground.SetFullscreen();
   }

   // Called once per frame when it is time to draw
   void EVENT_onRender
   {
      Sprite::Begin();
      m_sprBackground.Draw();
      Sprite::End();
   }

   // Called when the user taps on the screen
   void EVENT_onClick
   {
      Layers::Stack::GetInstance() -= this;
   }

private:
   Sprite m_sprBackground;
};
</pre></p>
<p>And the code to add this layer to the stack (effectively pausing the game):</p>
<p><pre class="brush: cpp;">
Layers::Stack::GetInstance() += new Pause();
</pre></p>
<p>Simple, eh? You may have noticed the strange function signatures. Yes, this is C++ &#8211; I&#8217;ll explain the reasoning behind it in a future post <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>References:</strong></p>
<h6>1. <a href="http://depts.washington.edu/aimgroup/proj/dollar/">Wobbrock, J.O., Wilson, A.D. and Li, Y. (2007). Gestures without libraries, toolkits or training: A $1 recognizer for user interface prototypes.<br />
Proceedings of the ACM Symposium on User Interface Software and Technology (UIST &#8217;07).<br />
Newport, Rhode Island (October 7-10, 2007). New York: ACM Press, pp. 159-168.</a></h6>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matp.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matp.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matp.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=7&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matp.wordpress.com/2010/04/03/stratum-engine-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04f4ef45114fb14018fddbda96c231fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
		<item>
		<title>Welcome!</title>
		<link>http://matp.wordpress.com/2010/04/03/welcome/</link>
		<comments>http://matp.wordpress.com/2010/04/03/welcome/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 06:19:37 +0000</pubDate>
		<dc:creator>Matt</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://matp.wordpress.com/?p=5</guid>
		<description><![CDATA[Welcome to my new blog, where I will be posting various articles on the kind of tech we use in-house at SquidJuice.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=5&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Welcome to my new blog, where I will be posting various articles on the kind of tech we use in-house at SquidJuice.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/matp.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/matp.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/matp.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=matp.wordpress.com&amp;blog=1856111&amp;post=5&amp;subd=matp&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://matp.wordpress.com/2010/04/03/welcome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/04f4ef45114fb14018fddbda96c231fb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
