<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://codebetter.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Brian Peek [MVP C#] - All Comments</title><link>http://codebetter.com/blogs/brianpeek/default.aspx</link><description>A compendium of random uselessness.  Enjoy.</description><dc:language>en</dc:language><generator>CommunityServer 2007 (Build: 20416.853)</generator><item><title>XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#172363</link><pubDate>Mon, 24 Dec 2007 11:52:39 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:172363</guid><dc:creator>Brian Peek</dc:creator><description>&lt;p&gt;Update: This issue has been fixed in XNA Game Studio 2.0. Woo hoo! While working on my game for Maker&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=172363" width="1" height="1"&gt;</description></item><item><title>XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#172362</link><pubDate>Mon, 24 Dec 2007 11:52:36 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:172362</guid><dc:creator>BrianPeek.com</dc:creator><description>&lt;p&gt;Update: This issue has been fixed in XNA Game Studio 2.0. Woo hoo! While working on my game for Maker&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=172362" width="1" height="1"&gt;</description></item><item><title>Link Listing - July 16, 2007</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/07/16/microsoft-robotics-studio-and-lego-mindstorms-nxt.aspx#165709</link><pubDate>Tue, 17 Jul 2007 11:16:07 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:165709</guid><dc:creator>Christopher Steen</dc:creator><description>&lt;p&gt;Implementing duplex messaging with BizTalk Services [Via: gsusx ] Titan-IOC : A lightweight, flexible,...&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=165709" width="1" height="1"&gt;</description></item><item><title>re: C# MVP</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/07/02/c-mvp.aspx#165097</link><pubDate>Tue, 03 Jul 2007 02:20:53 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:165097</guid><dc:creator>Matthieu MEZIL</dc:creator><description>Congratulation&lt;img src="http://codebetter.com/aggbug.aspx?PostID=165097" width="1" height="1"&gt;</description></item><item><title>re: C# MVP</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/07/02/c-mvp.aspx#165054</link><pubDate>Mon, 02 Jul 2007 13:08:48 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:165054</guid><dc:creator>John Papa</dc:creator><description>&lt;p&gt;Congrats! Well deserved!&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=165054" width="1" height="1"&gt;</description></item><item><title>re: C# MVP</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/07/02/c-mvp.aspx#165052</link><pubDate>Mon, 02 Jul 2007 13:02:56 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:165052</guid><dc:creator>Sam Gentile</dc:creator><description>&lt;p&gt;Congrats!! Welcome!&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=165052" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#164833</link><pubDate>Wed, 27 Jun 2007 20:36:03 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:164833</guid><dc:creator>Brian Peek</dc:creator><description>&lt;p&gt;Dan,&lt;/p&gt;
&lt;p&gt;Not sure I understand...when/why would you be getting multiple updates in a single frame?&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=164833" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#164794</link><pubDate>Wed, 27 Jun 2007 13:01:01 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:164794</guid><dc:creator>Dan</dc:creator><description>Hi thanks for the quick reply.

That has cleared a lot up for me.  I had a poorly designed projectile class so have re done it to be more flexible and fit in better with my game.

How do I get round a situation such as the update gets called again before the timer refreshes (do i just ignore this as it is unlikely that the human eye will be able to notice such a small hiccup?) 

Thanks for you help

Dan
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=164794" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#164721</link><pubDate>Tue, 26 Jun 2007 20:44:23 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:164721</guid><dc:creator>Brian Peek</dc:creator><description>&lt;p&gt;Dan,&lt;/p&gt;
&lt;p&gt;I assume you're using XNA since you're posting here. &amp;nbsp;;)&lt;/p&gt;
&lt;p&gt;I'm not 100% sure I understand the question at hand, but I would be maintaining a list of projectiles and enumerating the list once per call to the XNA Update method. &amp;nbsp;Here I'd take the elapsed ticks passed into the Update method to determine how far each projectile would have moved in that time frame.&lt;/p&gt;
&lt;p&gt;So, you'd like have a Projectile class which contains its own update method, also taking in a TimeSpan of elapsed time since the last frame. &amp;nbsp;So, something like this in your main game screen (pseudo-code):&lt;/p&gt;
&lt;p&gt;void Update(GameTime time)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;foreach(Projectile p in projectiles)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;p.Update(time);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;void Draw(GameTime time)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;foreach(Projectile p in projectiles)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp;p.Draw(time);&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Then in your Projectile class (pseudo-code again):&lt;/p&gt;
&lt;p&gt;void Update(GameTime time)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt; &amp;nbsp;this.X = VelocityX * time.ElapsedTime.TotalMilliseconds;&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;Hope that makes some amount of sense. &amp;nbsp;If not, feel free to post back here, post to my forum at www.brianpeek.com or fire off an email to me at &amp;quot;my first name@my first and last name.com&amp;quot; . &amp;nbsp;:)&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=164721" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#164699</link><pubDate>Tue, 26 Jun 2007 15:10:38 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:164699</guid><dc:creator>Dan</dc:creator><description>Hi

I have just read your article with great interest.  I am writing an Xbox 360 game for my final year project at university.  The game is going to be loosely themed on Worms.

I have a projectile class that takes an accuracy (how many times it updates itself for the time spent in the air).  At the moment the accuracy is set at 0.001 so it uses these intervals to work out (x,y) at a given time.

The results are correct however i now need to make it perform at close to real time. Can you suggest a decent starting place to look for answers please.

Any advice would be appreciated.

Thanks

Dan&lt;img src="http://codebetter.com/aggbug.aspx?PostID=164699" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#163565</link><pubDate>Wed, 30 May 2007 17:49:47 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:163565</guid><dc:creator>Brian Peek</dc:creator><description>&lt;p&gt;Thanks for the link. &amp;nbsp;I've been bitten on the PC side by these inaccuracies in the past, but this time it wasn't the PC I found inaccurate in all of my testing, but the Xbox. &amp;nbsp;Unfortunately since the CompactFramework is new to this platform and the fact that it is the CF, my options for timing are limited.&lt;/p&gt;
&lt;p&gt;Also note that the issue I was having wasn't that I wouldn't get updates to the tick count fast enough, but the fact that the tick count was just plain wrong.&lt;/p&gt;
&lt;p&gt;My sample app that proved the point showed that the Stopwatch (which uses QPC internally on the 360) actually redefined the length of a millisecond. &amp;nbsp;:) &amp;nbsp;The sample app would start a Stopwatch and grab the time value for DateTime.UtcNow.Ticks and compare the two over time. &amp;nbsp;You can watch the difference between the two values increase at a constant rate such that after 1 minute, the value returned from DateTime.UtcNow.Ticks was indeed real time, and the value returned by the Stopwatch was 150ms in the past. &amp;nbsp;After 2 minutes, it was 300ms off. &amp;nbsp;After 3, 450ms.&lt;/p&gt;
&lt;p&gt;Quite bizarre, but according to the Stopwatch on the 360's CF, a millisecond isn't quite a milisecond, but DateTime.UtcNow.Ticks was perfectly accurate for my needs.&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=163565" width="1" height="1"&gt;</description></item><item><title>re: XNA Timing Bug</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/30/xna-timing-bug.aspx#163561</link><pubDate>Wed, 30 May 2007 12:58:38 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:163561</guid><dc:creator>cmyers</dc:creator><description>Brian,

You should Google on StopWatch and QueryPerformanceCounter, because you&amp;#39;re not alone on this. Many PC processors have this problem also, especially AMD ones and dual-core (AMD or Intel) ones.  There are ways of compensating for this.

As far as DateTime.Now and UtcNow, while the docs state that the RESOLUTION (accuracy) is 10 milliseconds, my observations have shown its PRECISION (repeatability/reliability) is around 200 milliseconds. For example, I&amp;#39;ve seen that repeated calls to dump DateTime.Now/UtcNow to the console in a tight loop will show that the value doesn&amp;#39;t change but once every 150-200ms.

I&amp;#39;ve tried this on Intel and AMD, single and dual core and the DateTime.Now/UtcNow are reliably imprecise and StopWatch/QueryPerformanceCounter can be all over the board (inaccurate, but precise, accurate but imprecise, etc). 

Here&amp;#39;s a good article from a guy working on a video editing app (which has the same kinds of timing requirements you have):
http://www.virtualdub.org/blog/pivot/entry.php?id=106&lt;img src="http://codebetter.com/aggbug.aspx?PostID=163561" width="1" height="1"&gt;</description></item><item><title>re: XNA and 3D Model Exporting</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/04/12/XNA-and-3D-Model-Exporting.aspx#163011</link><pubDate>Sun, 13 May 2007 07:29:59 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:163011</guid><dc:creator>eric</dc:creator><description>Great to know, i was haveing a similar problem in 3 differnet modeling aps becuase of something like this! If onlyi could get blender 3d to export to .x properly...&lt;img src="http://codebetter.com/aggbug.aspx?PostID=163011" width="1" height="1"&gt;</description></item><item><title>re: Maker Faire 2007</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/05/09/maker-faire-2007.aspx#162943</link><pubDate>Wed, 09 May 2007 23:57:23 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:162943</guid><dc:creator>Brendan Tompkins</dc:creator><description>Brian.. I&amp;#39;m a huge maker wannabe...  very cool that you&amp;#39;re going to be at the maker Faire!&lt;img src="http://codebetter.com/aggbug.aspx?PostID=162943" width="1" height="1"&gt;</description></item><item><title>re: Mix 07</title><link>http://codebetter.com/blogs/brianpeek/archive/2007/04/25/mix-07.aspx#162470</link><pubDate>Wed, 25 Apr 2007 20:48:56 GMT</pubDate><guid isPermaLink="false">d21fbbc9-c112-4f32-ad14-95939a2c53d4:162470</guid><dc:creator>Rod Paddock [MVP]</dc:creator><description>&lt;p&gt;I'll be there. Cell # is 253 906 2342 &lt;/p&gt;
&lt;p&gt;I'm at bellagio.&lt;/p&gt;
&lt;img src="http://codebetter.com/aggbug.aspx?PostID=162470" width="1" height="1"&gt;</description></item></channel></rss>