<?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>Christian Vucossa programming blog</title>
	<atom:link href="http://vucodev.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://vucodev.wordpress.com</link>
	<description>game programming, daily troubles and solutions</description>
	<lastBuildDate>Wed, 04 Nov 2009 10:06:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='vucodev.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Christian Vucossa programming blog</title>
		<link>http://vucodev.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://vucodev.wordpress.com/osd.xml" title="Christian Vucossa programming blog" />
	<atom:link rel='hub' href='http://vucodev.wordpress.com/?pushpress=hub'/>
		<item>
		<title>The Evil NHibernate&#8217;s NonUniqueObjectException !</title>
		<link>http://vucodev.wordpress.com/2009/11/04/the-evil-nhibernates-nonuniqueobjectexception/</link>
		<comments>http://vucodev.wordpress.com/2009/11/04/the-evil-nhibernates-nonuniqueobjectexception/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 10:06:31 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[exception solving]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=135</guid>
		<description><![CDATA[NonUniqueObjectException: this exception comes out when you try to save or update an object with the same id of another object that is already in the scope of  the NHibernate session.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=135&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I faced this ancient evil&#8230; and it almost destroyed me.</p>
<p>This exception comes out when you try to save or update an object with the same id of another object that is already in the scope of  the NHibernate session.</p>
<p>My scenario was this: I had to save the instance of an object. Well, I have to choose if use a Insert or an Update. To do so, I query the db in search of an object with the id of mine and act accordingly.</p>
<p>BUT, the query keeps in the session the instance of the object and the next Update operation fails with the NonUniqueObjectException. What to do? Well, in this case you have to send in update the same object the GetByID returns to you.</p>
<p>So:</p>
<p>1) Query the db and keep the instance of the object A it returns (if any)</p>
<p>2) Update A with the data you store in the original updated object B</p>
<p>3) Save A instead of directly save B</p>
<p>and you&#8217;ll defeat the Evil NonUniqueObjectException!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/135/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/135/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/135/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=135&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/11/04/the-evil-nhibernates-nonuniqueobjectexception/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>S.A.D.: a space project</title>
		<link>http://vucodev.wordpress.com/2009/06/20/s-a-d-a-space-project/</link>
		<comments>http://vucodev.wordpress.com/2009/06/20/s-a-d-a-space-project/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 09:32:00 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[opengl]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=131</guid>
		<description><![CDATA[Just a couple of screenshot from my latest project, S.A.D. (Seek And Destroy), a 3D shooter in which you are a rookie that have to shoot down the vicious spy-satellites of an unknow alien force. This is the first time I face moving free across an empty 3d space&#8230; it&#8217;s not as simple as it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=131&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a couple of screenshot from my latest project, S.A.D. (Seek And Destroy), a 3D shooter in which you are a rookie that have to shoot down the vicious spy-satellites of an unknow alien force.</p>
<p>This is the first time I face moving free across an empty 3d space&#8230; it&#8217;s not as simple as it sounds!</p>
<p>But, well, here are the pictures:</p>
<p><img class="alignleft" title="SAD main menu" src="http://farm3.static.flickr.com/2431/3643602482_0254478b03.jpg?v=0" alt="" width="500" height="375" /></p>
<p>Models are self made and these are also my really first non-cube models! I used Blender for them, but I have not textured and also lights are turn off, so I render them as wireframe (for the player ship) or plain solid (the sat and the terrain).</p>
<p>I&#8217;m also using FTGL for the text rendering, I found it very simple and immediate (and pretty fast).</p>
<div class="wp-caption alignright" style="width: 510px"><img title="in game screen" src="http://farm4.static.flickr.com/3367/3643602426_e67fc67de0.jpg?v=0" alt="a spy sat in sight" width="500" height="373" /><p class="wp-caption-text">a spy sat in sight</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=131&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/06/20/s-a-d-a-space-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2431/3643602482_0254478b03.jpg?v=0" medium="image">
			<media:title type="html">SAD main menu</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3367/3643602426_e67fc67de0.jpg?v=0" medium="image">
			<media:title type="html">in game screen</media:title>
		</media:content>
	</item>
		<item>
		<title>Finite State Machine: a C++ implementation</title>
		<link>http://vucodev.wordpress.com/2009/05/29/finite-state-machine-a-c-implementation/</link>
		<comments>http://vucodev.wordpress.com/2009/05/29/finite-state-machine-a-c-implementation/#comments</comments>
		<pubDate>Fri, 29 May 2009 15:33:54 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[FSM]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=125</guid>
		<description><![CDATA[I think FSM are well used in game development, from purposes like AI to game state management.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=125&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those who don&#8217;t know what a FSM is, <a title="FSM by Wikipedia" href="http://en.wikipedia.org/wiki/Finite_state_machine">here</a> is a summary.</p>
<p>I think FSM are well used in game development, from purposes like AI to game state management.</p>
<p>You know, you have to deal with splash screens, menus, dialogs and so forth, and you need a way to <em>decide </em>what to put on screen at each loop. You can arrange your code into the BUS (aka Big Ugly Switch) and check for a state flag. This works, and I used it many times. Sure, it is not beauty nor elegant (after all, it&#8217;s Big and Ugly!) and, if you plan to add features (states) later, you must put other <em>case </em>statement. It is Big because it grows fast.</p>
<p>But there is another way to do the same. If you model your software in a sequence of states, each of them can receive input and generate output, and <em>something </em>catch this output and put on the field another appropriate state which can continue the work, well, you have an OO solution to your problem. Which means that it&#8217;s elegant. Which means that you can speak of it with your friends. Which is cool. Well, which is not the Big Ugly Switch&#8230;</p>
<p>FSM are this solution. I implemented a really basic version in C++. I have two classes:</p>
<ol>
<li>FSMState, which is a single state in my machine</li>
<li>FSMManager, which handle the states and make them work together.</li>
</ol>
<p>In addition, I put a couple of enums which are application-related&#8230; you can get rid of them and use simple int values.</p>
<p>So, here are my definitions (fsm.h)</p>
<blockquote><p>class FSMManager;</p>
<p>enum RawInputType<br />
{<br />
RIT_ESC, RIT_SPACE, RIT_AKEY<br />
};</p>
<p>enum HighInputType<br />
{<br />
HIT_IDLE=0, HIT_EXIT_GAME, HIT_SKIP_SPLASH<br />
};</p>
<p>enum StateId<br />
{<br />
// application states<br />
SID_IDLE=0, SID_SPLASH, SID_MENU, SID_BRIEFING, SID_PLAY, SID_PAUSE,<br />
SID_EXIT, SID_QUIT<br />
};</p>
<p>class FSMState<br />
{<br />
friend class FSMManager;</p>
<p>public:<br />
FSMState(int iId);</p>
<p>// methods to program the state<br />
void addInputPair(RawInputType, HighInputType);<br />
void addTransition(HighInputType, int);</p>
<p>// run the execution<br />
virtual void run();</p>
<p>protected:<br />
void sendInput(RawInputType);<br />
int getOutput();</p>
<p>private:<br />
int m_iId;<br />
HighInputType m_lastInput;<br />
std::map&lt;RawInputType, HighInputType&gt; m_inputTable;<br />
std::map&lt;HighInputType, int&gt; m_transitionTable;</p>
<p>};</p>
<p>class FSMManager<br />
{<br />
public:<br />
FSMManager();</p>
<p>void addState(FSMState*, bool current = false);<br />
void sendInput(RawInputType);<br />
FSMState* getCurrentState();</p>
<p>private:<br />
std::map&lt;int, FSMState*&gt; m_stateTable;<br />
FSMState* m_pCurrentState;<br />
};</p></blockquote>
<p>The RawInpuType and HighInputType enums are filled with some sample values. The first maps a physical input, such the ESC key press. The second maps a logic input, application-related, such as &#8220;Player want to exit&#8221;.</p>
<p>FSMState has three public methods, one of them virtual:</p>
<ol>
<li>addInputPair simply maps physical inputs with logic inputs, in a way that is coherent with the state logic (ESC key may means &#8220;Exit from game&#8221; in the menu screen, but may means &#8220;Go to menu&#8221; while playing).</li>
<li>addTransition maps the relative state to which go after a logic input is triggered. Each state has an ID which identify it (in this case it follows the StateId enums, but I used an int cause I plan to use this design to implement some AI too).</li>
<li>run is virtual because real states will inherit from this class and reimplement. For test purposes I left it virtual and not pure virtual, but you can think of it as a pure virtual if you want.</li>
</ol>
<p>The FSMManager class has a collection of states (pushed in via the addState method), but only one of them is the current state. Current state receive the raw input (which comes from another component, not present in this design) and produces an output (a new state if there is a transition, or itself) which updates the current state itself. This way a single input catching routine can pass the input through the FSMManager to the actual state, which has been programmed to give a result and maybe do a transition. At every loop the run method is called for the current state, which can perform drawings or just some logic (update of other object&#8217;s state or&#8230; what else you need).</p>
<p>Implementation of these methods are quite straight and boring. I put only the sendInput of the FSMManager, which actually performs the inner state transition:</p>
<blockquote><p>void FSMManager::sendInput(RawInputType raw)<br />
{<br />
if(m_pCurrentState != 0)<br />
{<br />
m_pCurrentState-&gt;sendInput(raw);</p>
<p>int output = m_pCurrentState-&gt;getOutput();<br />
map&lt;int, FSMState*&gt;::iterator imap = m_stateTable.find(output);<br />
if(imap != m_stateTable.end())<br />
{<br />
m_pCurrentState = imap-&gt;second;<br />
}<br />
else<br />
{<br />
// no state change<br />
}<br />
}<br />
}</p></blockquote>
<p>That&#8217;s all, bye.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/125/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/125/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/125/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=125&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/05/29/finite-state-machine-a-c-implementation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio .NET 2003 lib path limit</title>
		<link>http://vucodev.wordpress.com/2009/05/22/visual-studio-net-2003-lib-path-limit/</link>
		<comments>http://vucodev.wordpress.com/2009/05/22/visual-studio-net-2003-lib-path-limit/#comments</comments>
		<pubDate>Fri, 22 May 2009 14:18:31 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[exception solving]]></category>
		<category><![CDATA[vs2003]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=123</guid>
		<description><![CDATA[Yes, it is. The include lib path in Visual Studio .NET 2003 (C++) has a lenght limit, something about 2k (I haven&#8217;t measured precisely). So, if you run into the ugly LNK1104 fatal error and there is nothing wrong on your settings, maybe you have a too long lib list. Now, far from me the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=123&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yes, it is. The include lib path in Visual Studio .NET 2003 (C++) has a lenght limit, something about 2k (I haven&#8217;t measured precisely). So, if you run into the ugly LNK1104 fatal error and there is nothing wrong on your settings, maybe you have a too long lib list.</p>
<p>Now, far from me the will to debate if this is a silly limitation, after all one could say that a more than 2k lenght lib path list is far more silly too.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/123/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/123/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/123/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=123&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/05/22/visual-studio-net-2003-lib-path-limit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>ASP.Net Repeater updated with Ajax</title>
		<link>http://vucodev.wordpress.com/2009/03/21/aspnet-repeater-updated-with-ajax/</link>
		<comments>http://vucodev.wordpress.com/2009/03/21/aspnet-repeater-updated-with-ajax/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 12:28:43 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[various]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c-sharp (c#)]]></category>
		<category><![CDATA[Repeater]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=119</guid>
		<description><![CDATA[Here we have a very simple method which doesn't make use of any server side ajax component, just the old plain asp:Repeater and a good javascript ajax library.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=119&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a simple method to update an aspnet Repeater calling a server method via ajax&#8230; here we go!</p>
<p>We make the ajax call with the favourite js framework or none at all. I use prototype anyway.</p>
<p>In our server method we do something like this:</p>
<blockquote><p>List&lt;Item&gt; tobound = myDao.GetItems();</p>
<p>myRepeater.DataSource = tobound;</p>
<p>myRepeater.DataBind();</p>
<p>// and now the magic</p>
<p>// first of all we instance some usefull objects:</p>
<p>MemoryStream stream = new MemoryStream();</p>
<p>StreamWriter sw = new StreamWriter(stream);</p>
<p>HtmlTextWriter htw = new HtmlTextWriter(sw);</p>
<p>// then, we call the repeater&#8217;s own render method to render on our stream:</p>
<p>myRepeater.RenderControl(htw);</p>
<p>sw.Flush();</p>
<p>// ok, now we swap the stream in a byte array</p>
<p>Byte[] content = new Byte[stream.Length];</p>
<p>stream.Position = 0;</p>
<p>stream.Read(content, 0, stream.Length);</p>
<p>// and finally we transform the byte array in a string</p>
<p>string strContent = new System.Text.ASCIIEncoding().GetString(content);</p>
<p>// now strContent contains all the xhtml code that renders our repeater.</p>
<p>// Simply put it in the response and let it be consumed by the javascript callback</p>
<p>Page.Response.Write(strContent);</p></blockquote>
<p>And our client code in the callback will look like this:</p>
<blockquote><p>$(&#8216;myrepeaterdiv&#8217;).update(transport.responseText);</p></blockquote>
<p>Here we have a very simple method which doesn&#8217;t make use of any server side ajax component, just the old plain asp:Repeater and a good javascript ajax library.</p>
<p>Bye!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/119/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/119/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/119/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=119&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/03/21/aspnet-repeater-updated-with-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>Death and rebirth: my own roguelike reloaded</title>
		<link>http://vucodev.wordpress.com/2009/02/11/death-and-rebirth-my-own-roguelike-transformed/</link>
		<comments>http://vucodev.wordpress.com/2009/02/11/death-and-rebirth-my-own-roguelike-transformed/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:12:55 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[roguelike]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=113</guid>
		<description><![CDATA[The new project is something more... mature. Its codename is Dunia. I have a couple of great ideas, but I don't want to tell about them now because of the fear of can't accomplish them.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=113&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi there! Time to spend some words on what my Xarr project has been.</p>
<p>Project is dead, but it was not a death without a sense. It teached me a lot on OpenGL, but my goal was to make a roguelike, and so I switched to the classic ASCII style, embracing the *curses libraries, because graphic issues was becoming overwhelming and my interests was in the game not in the graphics mechanics this time.</p>
<p>Xarr is ended with my @ wandering in a maze and with a couple of S randomly moving all around. Good enough to end a demo.</p>
<p>The new project is something more&#8230; mature. Its codename is Dunia. I have a couple of great ideas, but I don&#8217;t want to tell about them now because of the fear of can&#8217;t accomplish them.</p>
<p>Up to now, Dunia comes with a @ exploring a loaded map. I said &#8220;exploring&#8221;, not &#8220;wandering&#8221;, because a field of view algorithm has been implemented, as written <a title="Bresenham based field of view" href="http://vucodev.wordpress.com/2009/01/20/line-of-sight-algorithm-bresenham/">here</a>.</p>
<p>Also, a &#8220;look&#8221; command has been implemented, as well as a &#8220;grab&#8221; command, a &#8220;drop&#8221; command and a &#8220;view inventory&#8221; one.</p>
<p>Oh, and there is also an &#8220;open&#8221; command! @ can move in all directions and collisions are rightfully detected.</p>
<p>The map features plain walkable squares, walls, doors (opened and closed) and furnitures. I defined &#8220;furnitures&#8221; all the items the player cannot grab, such as statues, but that are sensible to the look command. A nice feature a suppose.</p>
<p>By now I have only one kind of item: food. What else?!?</p>
<p><div class="wp-caption alignnone" style="width: 510px"><img title="Dunia " src="http://farm4.static.flickr.com/3430/3273013510_1ba4ed34c3.jpg?v=0" alt="The look command in action" width="500" height="234" /><p class="wp-caption-text">The look command in action</p></div><br />
<div class="wp-caption alignnone" style="width: 510px"><img title="Dunia" src="http://farm4.static.flickr.com/3380/3272193989_b5593b7efc.jpg?v=0" alt="The inventory screen and the drop command" width="500" height="236" /><p class="wp-caption-text">The inventory screen and the drop command</p></div></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/113/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/113/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/113/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=113&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/02/11/death-and-rebirth-my-own-roguelike-transformed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3430/3273013510_1ba4ed34c3.jpg?v=0" medium="image">
			<media:title type="html">Dunia </media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3380/3272193989_b5593b7efc.jpg?v=0" medium="image">
			<media:title type="html">Dunia</media:title>
		</media:content>
	</item>
		<item>
		<title>DataGridView Cell&#8217;s editing: handle user&#8217;s input</title>
		<link>http://vucodev.wordpress.com/2009/01/27/datagridview-cells-editing-handle-users-input/</link>
		<comments>http://vucodev.wordpress.com/2009/01/27/datagridview-cells-editing-handle-users-input/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 16:15:21 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[exception solving]]></category>
		<category><![CDATA[various]]></category>
		<category><![CDATA[c-sharp (c#)]]></category>
		<category><![CDATA[DataGridView]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=109</guid>
		<description><![CDATA[My need was to intercept all the '.' chars inputed by the user on a DataGridView cell and replace them with commas. With my big surprise, I have not found any suitable event of method.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=109&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I faced an issue that stole me a couple of hours of lazy work&#8230; My need was to intercept all the &#8216;.&#8217; chars inputed by the user on a DataGridView cell and replace them with commas. With my big surprise, I have not found any suitable event of method.</p>
<p>After a coffebreak, I returned with clear mind and restored energies at the problem and I found this event on the DataGridView object:</p>
<blockquote><p>EditingControlShowing</p></blockquote>
<p>Neither the name nor the help tooltip of the intellisense help me so much understanding its behavior, but I registered to it and took a try.</p>
<p>Its DataGridViewEditingControlShowingEventArgs provide me with a Control object that is exactly the control used by the cell to handle input, a TextBox in my case. And now the magic.</p>
<p>I tried to treat the control as a normal TextBox, registering to its KeyPress event and it works!</p>
<blockquote><p>myGrid.EditingControlShowing+=new DataGridViewEditingControlShowingEventHandler(myGrid_EditingControlShowing);</p>
<p>&#8230;</p>
<p>private void myGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) {<br />
if (e.Control is TextBox) {<br />
((TextBox)e.Control).KeyPress +=new KeyPressEventHandler(HandleKeyPress);<br />
}<br />
}</p>
<p>private void HandleKeyPress(object sender, KeyPressEventArgs e) {<br />
// My stuff here&#8230;<br />
}</p></blockquote>
<p>Another day at work, another .NET  trick learned&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=109&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/01/27/datagridview-cells-editing-handle-users-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>Line of Sight algorithm: Bresenham</title>
		<link>http://vucodev.wordpress.com/2009/01/20/line-of-sight-algorithm-bresenham/</link>
		<comments>http://vucodev.wordpress.com/2009/01/20/line-of-sight-algorithm-bresenham/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 11:19:08 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[bresenham]]></category>
		<category><![CDATA[line of sight]]></category>
		<category><![CDATA[los]]></category>
		<category><![CDATA[roguelike]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=106</guid>
		<description><![CDATA[This issue is known as Field of View. In a roguelike, player lives in a grid-world. His field of view are the tile he can see all around, given a certain range (influenced tipically by lighting). One of the possible methods to resolve this is using a line of sight algorithm, usefull also in other circumstances.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=106&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>While I was working at my roguelike I faced the issue of what player can see.</p>
<p>This issue is known as Field of View. In a roguelike, player lives in a grid-world. His field of view are the tile he can see all around, given a certain range (influenced tipically by lighting). One of the possible methods to resolve this is using a line of sight algorithm, usefull also in other circumstances.</p>
<p>The plot is simple. Can player see from his position A to position B? If a rect line can be traced from A to B without passing through an obstruction (wall or whatever) he can.</p>
<p>Calling this for every end point of the area around the player results in the field of view. Sound simple, but it&#8217;s a bit tricky to implement.</p>
<p>I started with a couple of implementation of mine, based on the rect-between-two-points equation, that sounds like this:</p>
<blockquote><p>(y &#8211; y0)(x1 &#8211; x0) = (x &#8211; x0)(y1 &#8211; y0)</p></blockquote>
<p>and I reached a quite good result. In my game, player has a sight of 6, which means he can see at 6 cells, or tiles, around him. With this, almost the full area was correctly filled but some cells did not obey rightly.</p>
<p>After a bit of headache I opted for google and found <a title="Bresenham line drawing" href="http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html" target="_blank">this nice article</a> on Bresenham line drawing alg.</p>
<p>Copy/paste on my routine, made some little edit and the result is pretty good. If you are looking for a line of sight algorithm I suggest it. It worked for me.</p>
<p>Bye.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=106&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/01/20/line-of-sight-algorithm-bresenham/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>
	</item>
		<item>
		<title>My Own Roguelike Part 3: Loading/Saving</title>
		<link>http://vucodev.wordpress.com/2009/01/01/my-own-roguelike-part-3-loadingsaving/</link>
		<comments>http://vucodev.wordpress.com/2009/01/01/my-own-roguelike-part-3-loadingsaving/#comments</comments>
		<pubDate>Thu, 01 Jan 2009 18:16:47 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[game programming]]></category>
		<category><![CDATA[roguelike]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=101</guid>
		<description><![CDATA[I made some progress and archived part 2. Now the camera follow player in a correct way (thanx Tristam! ) and I haven&#8217;t the blinking problem yet. I&#8217;ve added a &#8220;tell me what I&#8217;m doing&#8221; feature to the message handling component, so that now a green writing serves as narrating voice at every action the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=101&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I made some progress and archived part 2. Now the camera follow player in a correct way (thanx Tristam! <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ) and I haven&#8217;t the blinking problem yet. I&#8217;ve added a &#8220;tell me what I&#8217;m doing&#8221; feature to the message handling component, so that now a green writing serves as narrating voice at every action the player performs (walking, up to now). Collision detection with walls is also active, and a &#8220;Ouch!&#8221; message appears when it happens.</p>
<p>I positioned the camera higher and more distant, in order to haven&#8217;t to rotate the view to see the hero when a wall is between.</p>
<p>Now I have to make the loading/saving routines. I already made a load function that loads a map of arbitrary dimension and it works great. Screenshot shows this feature in a 15&#215;21 map.</p>
<p>I&#8217;m very excited because, after the save method, I will enter in the real domain of the project: monsters and interaction! Bye!</p>
<div class="wp-caption aligncenter" style="width: 510px"><img title="the load map feature" src="http://farm4.static.flickr.com/3106/3156094765_1def720807.jpg?v=0" alt="the load map feature" width="500" height="371" /><p class="wp-caption-text">the load map feature</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=101&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2009/01/01/my-own-roguelike-part-3-loadingsaving/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>

		<media:content url="http://farm4.static.flickr.com/3106/3156094765_1def720807.jpg?v=0" medium="image">
			<media:title type="html">the load map feature</media:title>
		</media:content>
	</item>
		<item>
		<title>The float to int conversion&#8217;s big mystery</title>
		<link>http://vucodev.wordpress.com/2008/12/31/the-float-to-int-conversion-big-mystery/</link>
		<comments>http://vucodev.wordpress.com/2008/12/31/the-float-to-int-conversion-big-mystery/#comments</comments>
		<pubDate>Wed, 31 Dec 2008 18:13:16 +0000</pubDate>
		<dc:creator>Christian</dc:creator>
				<category><![CDATA[exception solving]]></category>
		<category><![CDATA[c++]]></category>

		<guid isPermaLink="false">http://vucodev.wordpress.com/?p=94</guid>
		<description><![CDATA[Someone must explain me this thing&#8230; I was working on my roguelike, namely the wall collision, when I came across one of the strangest things seen recently. My issue was to convert space coordinate of my @ into 2d matrix coordinate of the map, a bi-dimensional array. My space2map function perform some calculation and give [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=94&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Someone must explain me this thing&#8230; I was working on my roguelike, namely the wall collision, when I came across one of the strangest things seen recently. My issue was to convert space coordinate of my @ into 2d matrix coordinate of the map, a bi-dimensional array. My space2map function perform some calculation and give me a x,y values, quite straight.</p>
<p>It seemed to work, but after a bit of testing things began to go wrong&#8230; when I was expecting a 2 I get a 1 instead, or the like. For some debugging hours I was sure I was wrong, but in the end I found myself in front of a thing like this:</p>
<blockquote><p>(0.2 + 0.3) / 0.5 = 0</p></blockquote>
<p>It was enough to make me think that yes, math is an opinion. A compiler opinion, at least.</p>
<p>After a while google gave me the answer: there is something on the float to int conversion. A really magic function came with the answer, this:</p>
<blockquote><p>int iround(float x)<br />
{<br />
return (int)floor(x + 0.5);<br />
}</p></blockquote>
<p>where floor() is the math.h C function.</p>
<p>I tried with this and it works. Then, I wrote a simple program to test this mystery, and this is the result:</p>
<div id="attachment_97" class="wp-caption aligncenter" style="width: 603px"><img class="size-full wp-image-97" title="screenshot-21" src="http://vucodev.files.wordpress.com/2008/12/screenshot-21.png" alt="The float to int test" width="593" height="395" /><p class="wp-caption-text">The float to int test</p></div>
<p>For the record, this happens on GCC for Ubuntu 8.04.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/vucodev.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/vucodev.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/vucodev.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=vucodev.wordpress.com&amp;blog=5794242&amp;post=94&amp;subd=vucodev&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://vucodev.wordpress.com/2008/12/31/the-float-to-int-conversion-big-mystery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/d89d2da79a1ff3594726443b0de19f6b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">vucodev</media:title>
		</media:content>

		<media:content url="http://vucodev.files.wordpress.com/2008/12/screenshot-21.png" medium="image">
			<media:title type="html">screenshot-21</media:title>
		</media:content>
	</item>
	</channel>
</rss>
