waheyluggage

Hello
Any advice on what's the best practice for setting up your game to run on both PC and Xbox Even better if there could be an included example of this.
I'd like to develop my game on the PC and only running the 360 version periodically. In the past I've set up seperate builds so I'd have a release\debug versions for PC, PS2 and Xbox1.
I've seen posts mentioning creating one solution with two projects in and then adding the source to the other project as a link. I have my project like this but I find I'm having to add any new source files twice, once to the PC version and once to the 360 version. The same goes for any data I decide to add. This doesn't seem the best way of dealing with it so has anybody come across a better solution
Any ideas
Thanks
Scott


Re: XNA Game Studio Express Setting project up to be cross platform

Stephen Styrchak - MSFT

There really isn't a better solution available today. In order to compile a single project for both Xbox 360 and Windows, it means the C# project has to have different references for each configuration. The VS IDE doesn't handle changing references very well, even though msbuild can handle it.

Although our current design allows simple cases to work, it doesn't take much effort to get "outside the lines," where features in the IDE break because the references have changed and the IDE doesn't expect it. Enough stuff can go wrong that we're not willing to support anyone who tries this.

I'm currently investigating ways to properly support a single project that can target both Xbox 360 and Windows. We're getting close to trying to decide whether the amount of work required adds enough value to make it worthwhile (it's starting to look like a lot of work). We're also weighing the value of making it possible, but with certain restrictions in place so that some features are unsupported (ie, if you use them, they may or may not work -- this is obviously cheaper for us to implement).

How important would this feature be to you How frequently do you think you'd switch from one platform to another Do you know what a batch build is, and do you care about that feature

I'm interested in hearing your opinions on this subject (and the opinions of anyone else reading). It's hard for us to tell whether working with two projects is easy enough as it is -- which makes us wonder if we should put our effort into another feature.

If you were stack-ranking your wishlist for upgrades in the tools for our next version, where would "cross-platform project" stand

--Stephen





Re: XNA Game Studio Express Setting project up to be cross platform

troydawson

This is like #1 for me right now. Development goes a lot faster staying on the PC. Plus the xbox on my desk makes noise. . .

I'm looking at sharing code via assemblies now. Platform-specific stub projects with the bulk of the code in a shared assembly is certainly an acceptable work-around for me.





Re: XNA Game Studio Express Setting project up to be cross platform

DarthFahza

Here's another aspect to this question (if too far off topic, I'll start a new thread)

For the Xbox360 XNA is using the Compact Framework.

Does that make it easy to convert a game for a mobile platform And if so, that would be another Project type to consider.

Back to the Win/Xbox, can an XNA Class Libraries be used in a Windows XNA Project and a Xbox XNA Project





Re: XNA Game Studio Express Setting project up to be cross platform

waheyluggage

Thanks for the reply, I can see how it would be tricky to sort out.
It's hard to say how important the feature would be at the moment as I'm generally just poking around in a few bits of code. You can bet it will get more important the more source and data I start adding - it's mainly the inconvenience of having to add the code\data to both projects. I just know I'm going to click Add rather than Add Link at some point as well, can't wait for that one. One of the pro's of having it as is though is that any differences between the two versions are easy to accomodate whether data or code. If there was some kind of add-in that could automate the task then that would be enough for me - maybe run through the current project and any source\data that are in the current but not in the destination it adds them as links. Not even sure if that's possible though..
If we're talking tools then I can't think of one that I would want more as it stands - mainly because I can't think of many tools that I need to be honest. It's certainly not a case of 'gah - this is terrible', more of a 'I wish it was a little smoother'. A lot of it's down to how well the cross platform code works though, if I was having to tweak a lot of source and\or data then the current solution would seem a whole lot better. Currently, everything I have is linked.
I'd be interested to hear how troydawson's workaround, ermm, works as it sounds like it may do the trick.




Re: XNA Game Studio Express Setting project up to be cross platform

Stephen Styrchak - MSFT

If you're talking about compiling one assembly and then referencing the same assembly from both your Xbox 360 and Windows game projects, I strongly recommend you do not do that. We do not support retargeting in that way -- meaning you can easily write code that will eventually fail on one platform or another.

If you decide to try anyway, note that it is an unsupported scenario and not likely to work as well as you'd hoped.

--Stephen





Re: XNA Game Studio Express Setting project up to be cross platform

omniGames

@Stephen Styrchak...

I think a cross-platform compiler would be used by many people, myself included. My plan is to develop on the PC first then port my game to the 360. A cross-platform compiler would DEFINITELY make this transition easier!

What I'm doing for now, and what is illustrated in the few examples, is wrapping platform-specific code with #if-#endif statements.

For example...

#if !XBOX
// perform mouse operations here
#endif

The examples in the help files use this method when, for example, calculating screen resolution and dimensions. At least this way, you don't have to keep two copies of the same code, you just have to break out the platform-specific code as separate algorithms (which you would have to do anyway).

This isn't "ideal" but for now, it's probably the easiest way to go.
Hope that helps!





Re: XNA Game Studio Express Setting project up to be cross platform

DarthFahza

Thanks for the warning Stephen.
Yes I was thinking about using referencing a class libary assembly from a win and xbox project.
Like what TroyDawson posted.

Would it be safe to do for low level things like utility methods

Maybe I should just ask, what method/technique does the XNA team recommend for maximum code re-use between a game developed for Windows and Xbox360





Re: XNA Game Studio Express Setting project up to be cross platform

waruwaru

XBox 360 is aiming to be the center piece of home media center. I think it is un-reasonable to expect XGSE hobbyists to hog the entire home theatre setup just for game dev purpose. It would be even harder to justify a 2nd X360 + TV just for dev purpose. I think not providing cross-platform development will further limit/decrease the appeal of the Creator Club. Cross platform dev will make our lives so much easier. :D




Re: XNA Game Studio Express Setting project up to be cross platform

Stephen Styrchak - MSFT

Just to be clear, we use the same C# compiler for both platforms already. The difference is in the runtime and the framework. The XNA Framework API (the Microsoft.Xna.* class libraries used for XNA games) is already almost the same for both platforms. For the parts that differ, you will always need to use conditional-compilation flags so that you can re-use the same source files.

Right now, the way we recommend doing cross-platform development is to create a second project and add all the source files and content files from the original as links. That way, both projects share the same source files (you have to use Add As Link so that both project point to the same file instead of each getting their own copy).

Thanks for the feedback everyone.

--Stephen





Re: XNA Game Studio Express Setting project up to be cross platform

Epsicode

My only problem with the "2 seperate projects" solution is that I have to manually add every content folder and subfolder then all ressources as link when converting for the first time.
I wish that there could be a way to "link" an entire folder in one step (for the content pipeline's ressources at least).

Of course I can live without that.





Re: XNA Game Studio Express Setting project up to be cross platform

waheyluggage

There's only a couple of things wrong with the 2 seperate projects that I've found so far...
* Can be irritating adding the source\data files once you've added a lot of data in different folders or adding several new classes.
* Easy to click Add rather than Add As Link - it's ok if you realise it but if you make a mistake and you're not observant you can end up with a bit of a headache.
* You can select a different project\platform when you use the dropdown menu at the top next to debug. But if you hit F5 it still gets the wrong one. ie. I change the x86 to Xbox 360 and hit F5 to build and run - instead of it building\deploying the 360 version it does the x86 version. You have to right click the 360 project and click "Set as Startup Project" to get F5 to pay attention to the right build.