# XNA Development on PC but Designing for Xbox 360

I'm working on a project with a buddy, he doesn't have a 360 nor does he have the money to get one right now, but we want our game to be submitted to XBLIG. So right now we're both designing our game on the PC but we're using adapted 360 controllers. What are the things we need to keep in mind during the process so that we can "easily" port our game to the 360 from the PC?

• I'm not too sure this is good as a question. It should become a community question, since the only good answer would be a checklist combining all other answers. – Elideb Apr 25 '12 at 9:25
• By the way, if one of you has a 360 you can still test the project without issues. From Visual Studio you can create a copy of the game and libraries targeting Xbox 360, sharing all code and assets with the PC version. The files will be exactly the same ones, so you'll just have to use compiler directives in very specific sections of the code. – Elideb Apr 25 '12 at 11:50
• Being such a nub game designer at this point in my career I hadn't realized I'd asked such a broad question. There are some great answers here, I'm just not sure which to select. – Lester Peabody Apr 25 '12 at 12:20
• I wouldn't select any, but create a new one compiling all of them and mark it as a Community Wiki (CW) answer. But don't worry much about that. Even I'm not too sure how the CW stat should be handled. For reference: What are Community Wiki posts? – Elideb Apr 25 '12 at 21:21
• Yeah there's so much good information here that it definitely warrants a community wiki answer, at least I think it does after glancing through the CW FAQ. I actually flagged the mod to make it community wiki, but I'll create a separate answer in the interim. – Lester Peabody Apr 26 '12 at 2:27

You have to keep in mind that the Xbox360 has far poorer .NET performance than your average desktop PC (and a limited subset of it too!).

There are two main reasons: the Load/Hit/Store penalty (due to the architecture of the CPU/RAM/GPU) and the non-generational Garbage Collector.

For GC issues, which cause 'pauses' or 'freezes' in your game during runtime, you want to avoid any kind of runtime garbage, so be very careful with Strings (never concatenate for instance), never allocate reference type objects after your initial loading (ie no var obj = new MyCoolObject();), and be careful with foreach. I've made a blog post some time ago that covers some of these points: http://nextstopnowhere.wordpress.com/2010/03/26/garbages-out-pools-are-in/

But whatever you do, you will have to test on the Xbox360, and the sooner the better.

• +100, Test on the xbox asap. Learn to hate new MyClass() and myString + myInt.ToString() – George Duckett Apr 24 '12 at 15:33
• @LesterPeabody There's a StringBuilder class in .NET too. Also, see this link. – David Gouveia Apr 24 '12 at 16:02
• Yes, StringBuilder is nice, but remember that creating one StringBuilder is creating a new object on the heap. And you have to use it without calling ToString(). That's possible with the XNA builtin SpriteBatch/SpriteFont text rendering. – jv42 Apr 24 '12 at 16:15
• @DavidGouveia that post, although true, is misleading when compared to the scope of this question. Yes, when operations are not in a loop is just won't matter, BUT if you are doing string concats in a loop on the 360. use the StringBuilder class. Not because it is faster, but because it will be less garbage for the GC to worry about. – Joe Apr 24 '12 at 16:21
• As a general case, avoid creating references that will be discarded right away. For those, use pools. References that will remain relevant AND referenced for a long time, there's no problem. Just make sure you don't free many of them in a gameplay section of your game. – Elideb Apr 25 '12 at 12:02

The best way is to periodically test the game in a console to check for performance problems or problematic garbage collections; otherwise you will end with a lengthy debugging and optimization session before publishing the game.

And when porting to Xbox 360, check all the cases specified in the peer review evil checklist.

• Think deserves a vote solely for the link to the checklist – Joe Apr 24 '12 at 15:59

No one seems to mention this, but be sure to, at the very least, compile your project for the X360 every day. The Xbox only features a subset of .NET (.NET Compact Framework 3.0), missing lots of interesting stuff like Tuples, some collections, optional parameters, etc., so you will get bitten if you rely on any of them and don't realize you shouldn't until too late in the project.