tag:blogger.com,1999:blog-58599812014-03-19T17:53:40.118-04:30Game Development and XNAby Juan CampaJuan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-5859981.post-47475250131984842512009-08-07T18:59:00.003-04:302009-08-07T19:10:05.957-04:30<span style="color: rgb(255, 255, 255); font-weight: bold;font-size:130%;" >I'm back</span><br /><br />I've been off for some time, I has been working on both the university and this great game we are creating at <a href="http://gaspgames.com/">gasp</a>, check out the trailer:<br /><br /><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/Rl7JD0Kcdio&amp;hl=en&amp;fs=1&amp;"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/Rl7JD0Kcdio&amp;hl=en&amp;fs=1&amp;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object><br /><br />I will be working on the console a little these days, fixing bugs like garbage generation and optimizing it in general, also I'll improve the python interpreter and add some scripts to do useful stuff.<br /><br /><span style="font-style: italic;">JG</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-41041957937714133432009-05-20T15:00:00.002-04:302009-05-20T15:06:40.342-04:30<span style="font-weight: bold; color: rgb(255, 255, 255);font-size:130%;" >The new stuff didn't come so soon, did it?</span><br />I'm sorry but I just haven't got the time to finish tweaking some minor details. I'll finish this release and upload as soon as I have some free time. The work and the university have been very time consuming these days.<br /><br /><span style="font-style: italic;">JG.</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-63598166763856467392009-03-20T18:15:00.003-04:302009-03-20T18:19:06.298-04:30<span style="font-weight: bold; color: rgb(255, 255, 255);font-size:130%;" ><span style="font-family: arial;">New stuff coming very soon.</span></span><br /><ul><li>Integrated python interpreter, thanks to <a href="http://www.codeplex.com/XnaConsole">Samuel Christie</a></li><li>Some useful scripts to trace variables</li><li>Mouse controller sliders to tweak your variables on runtime<br /></li><li>Logging</li><li>A lot more</li></ul>Stay tuned.<br /><br /><span style="font-style: italic;">JG</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com1tag:blogger.com,1999:blog-5859981.post-28504163384303559072009-03-10T11:55:00.007-04:302009-03-13T13:35:54.193-04:30<span style="font-size:130%;"><span style="color: rgb(255, 255, 255); font-weight: bold;font-family:arial;" >Debug Console - Second Release</span></span><br /><br />Hello, I fixed a lot of issues I had with the console I didn't know about.<br /><ul><li>I'm now using the same effect (an instance of XNA's BasicEffect) for every component.</li><li>Lines are now traceable. That is, each line you draw have a name, then when you draw a line with the same name, the previous line gets moved.</li><li>Some of you might had problems with the ShowLine and ShowMark methods, fixed.</li><li>I have created a new command parser in order to add scalability. You can now for example use <span style="color: rgb(255, 255, 255);font-family:courier new;" >Game1.console.Execute("trace Player1.position", position);</span> <span style="color: rgb(0, 0, 0);">and would be the same as using <span style="color: rgb(255, 255, 255);font-family:courier new;" >Game1.console.Show("Player1.position", position);</span>. This is because later I will add the feature to trace values <span style="font-weight: bold;">in runtime</span></span>, something that will decrease debugging time for your games.</li></ul>Things I need to fix:<br /><ul><li>console.DrawBox</li><li>console.Log</li><li>Test it on the XBOX<br /></li></ul>The <a href="http://debugconsole.codeplex.com/SourceControl/ListDownloadableCommits.aspx">code</a> is now commited. and here's the <a href="http://debugconsole.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24519">.dll library</a><br /><br /><span style="font-style: italic;">JG</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com3tag:blogger.com,1999:blog-5859981.post-34173091859172241292009-03-09T12:13:00.007-04:302009-03-11T09:10:16.854-04:30<span style="font-weight: bold; color: rgb(255, 255, 255);font-family:arial;font-size:130%;" ><span>LINQ Benchmark fixed.</span></span><br />I posted about the benchmark in the <a href="http://forums.xna.com/">Creators Club forums</a> and they explained me why these results were incorrect. I measured it wrong.<br />The thing is that on the LINQ test I wasn't actually running the query. To run it, I must at least iterate over the result, this is because the <a href="http://www.hookedonlinq.com/DeferredExecution.ashx">defered execution</a> of the IEnumerable implementation, and the <span style="font-weight: bold;">return yield</span> it runs.<br /><br />So I rewrote it, and the results came out more predictable, here you have them.<br /><br /></span><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_OtUicCPG4qE/SbVJT5hZqXI/AAAAAAAAAAc/NWrJraD8tpg/s1600-h/LINQ+Benchmarking+results+2.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 174px;" src="http://4.bp.blogspot.com/_OtUicCPG4qE/SbVJT5hZqXI/AAAAAAAAAAc/NWrJraD8tpg/s320/LINQ+Benchmarking+results+2.png" alt="" id="BLOGGER_PHOTO_ID_5311231941760625010" border="0" /></a>I also increased the valueCount to a hundred million values. And there you have it, even though LINQ version is more elegant, it took almost twice the time, so for time critical operation I would prefer avoiding it.<br /><br /><span style="font-style: italic;">JG</span><br /></span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-67851063952736298442009-03-05T12:58:00.005-04:302009-03-09T12:34:46.056-04:30<span xmlns=""><p><span style="color: rgb(255, 255, 255); font-family: arial; font-weight: bold;font-size:130%;" >LINQ Benchmark</span><br /></p><p>For those of you that doesn't know LINQ yet, it's a new technology from c# 3.0 that lets you run queries independently from your database, even on c# objects (like arrays, List, LinkedList, etc) with a SQL-like statement .<br /></p><p>Yesterday I was wondering how fast LINQ could run some queries compared to more traditional methods. I'm not talking about LINQ to SQL on an external database, but running a query on some IEnumerable object instead. So I created a small benchmark. I'm not sure if it is correct because there is some stuff that I might be timing erroneously, so please tell me if I should be considering things like JIT time, GC, or any other housekeeping.<br /></p><p>Anyway, on a very simple test the results came out unexpectedly.<br /></p><p>Here's the method I wrote:</p><!-- code formatted by http://manoli.net/csharpformat/ --><style type="text/css">br />.csharpcode, .csharpcode pre<br />{<br /> font-size: small;<br /> color: black;<br /> font-family: Consolas, "Courier New", Courier, Monospace;<br /> background-color: #ffffff;<br /> /*white-space: pre;*/<br />}<br /><br />.csharpcode pre { margin: 0em; }<br /><br />.csharpcode .rem { color: #008000; }<br /><br />.csharpcode .kwrd { color: #0000ff; }<br /><br />.csharpcode .str { color: #006080; }<br /><br />.csharpcode .op { color: #0000c0; }<br /><br />.csharpcode .preproc { color: #cc6633; }<br /><br />.csharpcode .asp { background-color: #ffff00; }<br /><br />.csharpcode .html { color: #800000; }<br /><br />.csharpcode .attr { color: #ff0000; }<br /><br />.csharpcode .alt <br />{<br /> background-color: #f4f4f4;<br /> width: 100%;<br /> margin: 0em;<br />}<br /><br />.csharpcode .lnum { color: #606060; }<br /></style><br /><pre class="csharpcode"><br /><span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)<br /> {<br /> <span class="kwrd">int</span> valueCount = 1000000;<br /> Random random = <span class="kwrd">new</span> Random();<br /> <span class="kwrd">float</span>[] values = <span class="kwrd">new</span> <span class="kwrd">float</span>[valueCount];<br /> <br /> Stopwatch timer;<br /> <span class="rem">// Initialize the values</span><br /> <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; valueCount; i++)<br /> {<br /> values[i] = random.Next(valueCount);<br /> }<br /> GC.Collect();<br /><br /> <br /> <span class="rem">// LINQ</span><br /> Console.WriteLine(<span class="str">"Try with the LINQ query"</span>);<br /> timer = Stopwatch.StartNew();<br /> IEnumerable&lt;<span class="kwrd">float</span>&gt; extracted1 = from v <span class="kwrd">in</span> values <span class="kwrd">where</span> v &lt; 500000 select v;<br /> timer.Stop();<br /> Console.WriteLine(timer.Elapsed.TotalSeconds);<br /> Console.ReadLine();<br /><br /> <span class="rem">// Regular for</span><br /> Console.WriteLine(<span class="str">"Try with the 'for' iteration"</span>);<br /> List&lt;<span class="kwrd">float</span>&gt; extracted2 = <span class="kwrd">new</span> List&lt;<span class="kwrd">float</span>&gt;();<br /> timer = Stopwatch.StartNew();<br /> <span class="kwrd">float</span> var;<br /> <span class="kwrd">for</span> (<span class="kwrd">int</span> i = 0; i &lt; valueCount; i++)<br /> {<br /> var = values[i];<br /> <span class="kwrd">if</span> (var &lt; 500000)<br /> extracted2.Add(var);<br /> }<br /> timer.Stop();<br /> Console.WriteLine(timer.Elapsed.TotalSeconds);<br /> Console.WriteLine(String.Format(<span class="str">"Counts: {0}, {1}"</span>, extracted1.Count(), extracted2.Count()));<br /> Console.ReadLine();<br /> }</pre><br /><p>It creates an array of random values ranging from 0 up to 1 million. Then both tests try to extract 500000 numbers from the values given the simple rule (x &lt; 500000). So here are the results:</p><p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_OtUicCPG4qE/SbANVvoJE5I/AAAAAAAAAAU/9yk0X1P8pg0/s1600-h/LINQ+Benchmarking+results.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 153px;" src="http://2.bp.blogspot.com/_OtUicCPG4qE/SbANVvoJE5I/AAAAAAAAAAU/9yk0X1P8pg0/s320/LINQ+Benchmarking+results.png" alt="" id="BLOGGER_PHOTO_ID_5309758627883062162" border="0" /></a></p><p>This is one of the results I got. LINQ was 50 times faster??? Am I measuring this wrong?</p><p><span style="font-style: italic;">JG</span><br /></p><p></p></span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com1tag:blogger.com,1999:blog-5859981.post-22412709815010262202009-02-21T03:00:00.002-04:302009-02-21T03:04:39.793-04:30Hey ya, next week I have planned to add the Log method, so you can keep a historical log of the runtime. Plus, i'll fix some minor bugs.<br />Another thing I should begin to care is "<span style="font-style: italic;">threadsafeness</span>", because sometimes calling methods from different threads can cause consistency problems.<br /><br /><span style="font-style: italic;">JG</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-50542094622957476672009-02-20T17:22:00.002-04:302009-02-20T17:24:41.264-04:30<span xmlns=""><p>Not much people have downloaded the console, so I decided I'll post the things you'll get by using it. Probably some of you are wondering, why use this crappy component if I have my old school .NET's Console.WriteLine(debugThis) that hasn't ever let me down?. I'll explain the neat features:</p><p>The main feature is the Show method. It receives two parameters: a string identifying what you are showing, and a value. For example: Console.Show("Player1.Position", pos); you can write this call inside the Update of your main character and a new variable will be added to the Console's TreeView, and everytime this gets called the value in the TreeView gets updated. Let me show you a screenshot.<span><span xmlns=""><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_OtUicCPG4qE/SZ8mf37hiEI/AAAAAAAAAAM/BLz2uzZpFVk/s1600-h/BlogPostScreen1.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 188px;" src="http://2.bp.blogspot.com/_OtUicCPG4qE/SZ8mf37hiEI/AAAAAAAAAAM/BLz2uzZpFVk/s320/BlogPostScreen1.png" alt="" id="BLOGGER_PHOTO_ID_5305001215097145410" border="0" /></a></span></span></p><p><br /> </p><p>So, as you can see you will get live coverage of some variables of interest, and they will stay right there, visible everytime you need them. Another thing to note is that the console creates a hierarchy of values, if you need some other variables from Player1 you will get them grouped under the same node so you can quickly check the state of some component of your game. I'm planning to use the reflection API to add variables from the console itself, for example you could write "Game.Player1.Position" at runtime and you will see the value being added and updated every frame, I'm not sure if the .NET reflection API is available on the XBOX.</p></span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com4tag:blogger.com,1999:blog-5859981.post-70670140944275668072009-02-18T00:49:00.009-04:302009-02-18T13:42:31.105-04:30<span style="font-style: italic;">Update: rewritten to be more clear.</span><br />I forgot to mention how to use the console. Here's what I do to add it to a new project:<br /><ol><li>Add the <a href="http://www.codeplex.com/debugconsole/Release/ProjectReleases.aspx?ReleaseId=23413">DebugConsole.dll</a> as a reference to your project.</li><li>Create a new <span style="font-weight: bold;">public </span>class file, call it GameInfo.cs</li><li>Make your new GameInfo class implement the DebugConsole.IContainGameInfo interface. (i.e change the line "public class GameInfo" for "public class GameInfo : DebugConsole.IContainGameInfo"<br /></li><li>Add the 4 <span style="font-weight: bold;">public properties </span>mentioned later to your GameInfo class</li><li>Create a <span style="font-weight: bold;">static </span>instance of the DebugConsole somewhere you can reach easily, something like Game1.Console (just add a DebugConsole variable in your Game1.cs file)<br /></li><li>Construct the console with a new GameInfo instance (i.e add <span style="color: rgb(0, 0, 0);font-family:courier new;font-size:100%;" >new DebugConsole.DebugConsole(new GameInfo());</span>to your initialize method)<br /></li><li>Add the console as a GameComponent (<span style="color: rgb(0, 0, 0);font-family:courier new;" >Game1.Components.Add(Game1.Console);</span>)</li><li>That's it. Start using the console (i.e <span style="color: rgb(0, 0, 0);font-family:courier new;" >Game1.Console.Show("My var", myLocalVar);</span>)</li></ol>This are the properties you need to add to GameInfo, just copy and paste and replace the comments:<br /><ul style="text-align: left; color: rgb(0, 0, 0);font-family:courier new;"><li style="font-family:courier new;"><span style="font-size:100%;">public Game Game { get { /* return your Game class here */ } }</span></li><li style="font-family:courier new;"><span style="font-size:100%;">public Matrix WorldMatrix { get { return Matrix.Identity; } }</span></li><li style="font-family:courier new;"><span style="font-size:100%;">public Matrix ViewMatrix { get { /* return your view matrix here */ } }</span></li><li style="font-family:courier new;"><span style="color: rgb(0, 0, 0);font-size:100%;" >public Matrix ProjectionMatrix { get { /* return your projection matrix here */ }</span></li></ul>If you have a 2D project, you can return Matrix.Identity in the View and Projection properties, but you won't be able to use marks.<br /><br />I will upload an example project soon.<br /><br /><span style="font-style: italic;">JG</span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-38665189647045806922009-02-17T22:29:00.005-04:302009-02-18T01:11:26.846-04:30Let me introduce you to the <a href="http://www.codeplex.com/debugconsole/Release/ProjectReleases.aspx?ReleaseId=23413">Debug Console for XNA</a>. It is designed to be an handy set of runtime tools you can use to debug your game. Right now it does not have too many features but it does have some that you may like.<br /><br /><span style="font-weight: bold;">Current Features</span><br /><ul><li><span style="font-weight: bold;">Show</span>. Live! watch of variables.</li><li><span style="font-weight: bold;">Alert</span>. A text that pops out to indicate when an event happens.</li><li><span style="font-weight: bold;">ShowMark</span>. Put some marks on the 3D space.</li><li><span style="font-weight: bold;">ShowLine</span>. Draw lines on the space.<span style="font-weight: bold;"></span></li><li><span style="font-weight: bold;">ShowBox</span>. Draw a box on the space (this is not currently in the DebugConsole, but in a matters of days will be).</li></ul><span style="font-weight: bold;">Planned:<br /></span><ul><li><span style="font-weight: bold;">ShowSphere</span>. self explained.<br /></li><li>Improve performance by making smarter use of the video card calls.</li><li>Improve the way matrices are passed to the console, to make it more flexible and comfortable.<br /></li></ul>If you're interested you can download the <a href="http://www.codeplex.com/debugconsole/SourceControl/ListDownloadableCommits.aspx">source code</a>.<br />I definitely want to get feedback from you, so leave a comment/bug report/feature request/anything else, whenever you want.<br /><br />UPDATE: Instructions on next post.<br /><br />Until next post,<br /><span style="font-style: italic;">JG</span><br /><br /><span style="font-weight: bold;"></span>Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-72778739072992032042009-02-09T11:20:00.000-04:302009-02-09T11:21:00.383-04:30<span style="font-weight:bold;">Test.</span><br><br />Are <span style="font-weight:bold;">you</span> reading this?Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com4tag:blogger.com,1999:blog-5859981.post-6479993125446111302009-02-05T19:23:00.004-04:302009-02-05T19:48:04.116-04:30Hey there, I haven't posted anything about XNA tools yet, that's right, and I feel bad about it. I'm going to be posting sometime soon. In the meantime check out the game we made for the <a href="http://globalgamejam.com">Global Game Jam</a>, here in Caracas.<br /><br />The Game Jam is a 48 hours event where you and your team create a small game. This year the first global Game Jam took place and 1600 participants around the globe worked to create more than 300 games.<br /><br />You can check out the games made here at Universidad Simón Bolívar <a href="http://globalgamejam.com/games?tid[]=25">here</a>.<br /><br />Our game was <a href="http://globalgamejam.com/games/gnaka-gnaka">Gnaka-Gnaka</a> (pronunced in Spanish ñaka-ñaka) written on XNA by these 8 persons<br /><br />Jose Alberto Gomez / Artist<br />Alex Perez / Sound Designer<br />Henry Quintero / Programmer<br />Alejandro Martinez / Graphics Programmer<br />Andres Barrera / Programmer<br />Luis Miguel Blanco / Programmer<br />Jose Dunia / Programmer<br />and me, also programming<br /><br /><br />We might be releasing it on the Xbox LIVE Community Games, in the meantime you can download it from the <a href="http://globalgamejam.com/games/gnaka-gnaka">link above</a>.<br />The game includes the Debug Console which I talked about before. You can use it if you like, later next week I'll be posting about it and offering a direct link to the code.<br /><br />See ya then.Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com0tag:blogger.com,1999:blog-5859981.post-63415074650017631832008-11-02T15:37:00.002-04:302008-11-02T15:53:38.073-04:30Ok. First of all I'm sorry about this post because probably some of you are expecting a post about the XNA tools and stuff, But I just havn't got the time to post about them... I'm sure next week i'll have some time off and I promise I'll finally begin to post about them. This post is to give some congrats to my <a href="http://battletennis.com">Team</a> because we won 2nd place on the <a href="http://dreambuildplay.com">Dream Build Play 2008 Competition</a> which I feel is quite a good achievement for our first game... Congratulations also to the other teams that made it to the end: <a href="http://gambit.mit.edu/">Gambit from Singapore</a> with "CarneyVale Showtime" (1st Place), Our team :) (2nd Place), Weapon of choice (3rd Place), and HuricaneX2 (with the 4th prize). The games just look fantastic... If you want more information check the Dream Build Play site (<a href="http://dreambuildplay.com">www.dreambuildplay.com</a>)Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com1tag:blogger.com,1999:blog-5859981.post-88868916537065733182008-10-07T02:00:00.008-04:302008-10-07T02:40:05.607-04:30Andy Patrick has a very <a href="http://bittermanandy.wordpress.com/">nice blog</a> about a game he's making, and he has written some posts about the tools that everyone involved in game programming should know about, you should definitely <a href="http://bittermanandy.wordpress.com/">check it out</a> if you are an XNA game programmer. These tools include: the CLRProfiler, PIX, <a href="http://www.lutzroeder.com/dotnet/">Reflector</a> (great one if you want to learn how XNA works internally), and some others. Since he already wrote about those very useful tools, (I haven't had the time to check out all of them) I'm gonna be talking about some other tools we're going to be using and some tools we are developing, especially a drop-in XNA debugging console I created for the development of Battle Tennis. I will be also adding some features to the console and sharing it with you (game devs) so you can use it for your own projects (and I can have some more feedback :). I'm going to be posting the console itself soon so stay tuned... By the way leave a comment or something if you're reading this so I know there's at least someone "tuned" ;)Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com3tag:blogger.com,1999:blog-5859981.post-9345177617234655092008-10-01T02:12:00.005-04:302008-10-06T02:12:28.916-04:30Hello, this is my first post, I'm one of the members of the Battle Tennis team, which is a game we are making here in Venezuela. Check out the video of our entry to the <a href="http://dreambuildplay.com/">DBP</a> competition. Hope you like it.<br /><br /><embed src="http://images.video.msn.com/flash/soapbox1_1.swf" id="h70vt0vr" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" pluginspage="http://macromedia.com/go/getflashplayer" flashvars="c=v&amp;v=7cacdd73-c857-4e70-812e-f9a2a76d829f&amp;ifs=true&amp;fr=msnvideo&amp;mkt=en-US" width="432" height="364"></embed><noembed>&amp;amp;amp;amp;amp;amp;amp;amp;lt;a href="http://video.msn.com/video.aspx?vid=7cacdd73-c857-4e70-812e-f9a2a76d829f" target="_new" title="Battle Tennis - Dream Build Play Trailer"&amp;amp;amp;amp;amp;amp;amp;amp;gt;Video: Battle Tennis - Dream Build Play Trailer&amp;amp;amp;amp;amp;amp;amp;amp;lt;/a&amp;amp;amp;amp;amp;amp;amp;amp;gt;</noembed><br /><br />This was made by a four people team:<br /><br />Jose Alberto Gomez (Artist)<br />Alex Perez (Music artist)<br />Alejandro Martinez (Programmer)<br />and myself, also a programmer.<br /><br />I will be posting about some of the tools that we made and used to get BT up and running, and game dev in general...Juan Campahttp://www.blogger.com/profile/11193739232351468647noreply@blogger.com2