<?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>f = ma &#187; patterns</title>
	<atom:link href="http://www.fysx.org/tag/patterns/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fysx.org</link>
	<description>gamedev, math, physics</description>
	<lastBuildDate>Tue, 31 Jan 2012 21:12:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>About the View in a Model-View-Controller</title>
		<link>http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/</link>
		<comments>http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 11:37:30 +0000</pubDate>
		<dc:creator>Martin Felis</dc:creator>
				<category><![CDATA[Links]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[patterns]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[view]]></category>

		<guid isPermaLink="false">http://www.fysx.org/?p=39</guid>
		<description><![CDATA[<a href="http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/" title="About the View in a Model-View-Controller"></a>I recently bought the third edition of the book &#8220;Game Coding Complete&#8221; from Mike McShaffry (a.k.a. MrMike) et al. which has been very delightful to read so far. I have been reading a few chapters which gave me a new &#8230;<p class="read-more"><a href="http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/" title="About the View in a Model-View-Controller"></a><p>I recently bought the third edition of the book &#8220;<a href="http://www.amazon.com/Game-Coding-Complete-Third-McShaffry/dp/1584506806" target="_blank">Game Coding Complete</a>&#8221; from <a href="http://www.mcshaffry.com/mrmike/" target="_blank">Mike McShaffry (a.k.a. MrMike)</a> et al. which has been very delightful to read so far. I have been reading a few chapters which gave me a new way of looking at game architecture and other things that I was convinced that I already understood them quite well.</p>
<p>One of them is the famously known <a href="http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29" target="_blank">Design Pattern</a>: the <a href="http://en.wikipedia.org/wiki/Model-View-Controller" target="_blank">Model-View-Controller</a>. To me, the Model always was the data that is being modified, the Controller takes care of the input (mouse, keyboard, maybe network, &#8230;) sent to the application and the View simply displays the data. If you want to improve graphics &#8211; you work on the View. You want to update keybindings in your input system &#8211; you&#8217;ll modify the Controller. Also the Controller keeps track of the player id that tells us which entity is being controlled by the player. Need a new type of vehicle / weapon? &#8211; Go to your Model (and of course, add code to the Controller and View to reflect them).</p>
<p>So far so good.</p>
<p>However in this book Mike gives an overview of a game architecture consisting of three basic parts: the Application Layer, the Game Logic and <em>multiple</em> Game Views. The Application layer hides the platform specific from the game and the Game Logic resembles what is going on in the game. The Game Views represent the game from different perspectives e.g. for a human player or a AI agent.</p>
<div id="attachment_50" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.fysx.org/files/2010/02/architecture.png"><img class="size-full wp-image-50" title="architecture" src="http://www.fysx.org/files/2010/02/architecture.png" alt="" width="400" height="165" /></a><p class="wp-caption-text">Game Architecture after Mike McShaffry</p></div>
<p style="text-align: center;">
<p>At first my head tried to map them onto a Model-View-Controller which failed as they resemble completely different things. Especially the description of the Game View gave me a different way of looking at the View in a Model-View-Controller. The Game View does not only<em> display</em> what is going on in the game, instead it also takes care of the <em>input handling</em>. More specific: the Game Views receive all the input events (key presses, etc.) and communicate with the Game Logic over events.</p>
<p>At first this seems a bit awkward concerning to what I wrote further up concerning the View, but giving the view the ability to receive input and send events has some nice properties. For example it might be &#8220;easier&#8221; to add a split-screen mechanic as each player has its own Game View (remember: we have <em>multiple</em> Game Views!) and also its own keybindings. Also one could imagine having a GameEditView which has completely different abilities than e.g. a HumanGameView. This gives the View more power as it also contains not only the way <em>how you look</em> at things but also <em>how you interact</em>.</p>
<p>Maybe I got it all mixed up, however I think it one shouldn&#8217;t be too strict on saying input is clearly handled in the Controller or that the job of a View is drawing only.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fysx.org/2010/02/25/about-the-view-in-a-model-view-controller/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

