tags:

views:

153

answers:

2

I asked this on the XNA forums but I guess since most people there would specialize in C# I didn't get much help with this

I have some code for a game written in Scala. I compile everything into Java Bytecode at the moment but the Scala compiler has a .Net version. With that in mind, and because modular design is good practice in general, I've written a Graphics interface and right now I use a OpenGLGraphics class implementing this interface which contains every line of OpenGL code in my program. In my perfect world I would be able to swap my OpenGLGraphics class out for an XNAGraphics class and run my game on an Xbox with no further porting, well, maybe some modifying, but I imagine it's not this simple.

I've done some googling and I've failed to find an example of anyone trying this. I do have experience with XNA programming and the first problem that comes to mind is that there is no scala plugin for Visual Studio and XNA programming seems to be very Visual Studio centric, can I at least get visual studio to compile non C# code in an XNA project or setup an XNA project and content pipeline without Visual Studio?

+3  A: 

You can configure arbitrary pre- and post-build events in the IDE by creating creating a C# project, right-clicking the project to open up the properties pages and selecting "Build Events". There should be a "Pre-build event command line" and "Post-build event command line" where you specify arbitrary commands to run as part of the build. However, possibly a better option would be to create MSBuild build files by hand and using the Exec task to run arbitrary commands.

There is some discussion about Scala integration into VS here which also discusses custom MSBuild tasks.

Richard Cook
A: 

as long as you can point the compiler to the correct version of the XNA assemblies, and it produces a proper CLR assembly, then your best bet would be to refactor all of your game code into a .dll/assembly. Then just make a regular XNA project as normal, reference your scala assembly, and just reference the code from the scala assembly to start up the XNA game.

to be sure, it would take some refactoring, but it sounds like you've already done most of the work by having an abstracted renderer and all that

Joel Martinez