Scala XNA

One of the things that I thought would be a really cool demonstration of Scala.Net was to have an XNA application that was coded completely in Scala. I have mixed news on the subject. I did successfully get an XNA window opened and the game loop running. However, as far as I can tell, all of the ways to draw in XNA rely on generics, which are not yet supported in Scala.Net.

After a short email exchange with Miguel, I was able to get Scala compiling against some of the XNA assemblies. This allowed me to extend the Game class and open an XNA window. The problem I was having was compiling the Scala against multiple dependent dlls. I expected the “Xassem-path”argument to take multiple parameters, one for each of the assemblies. Instead, the solution was to add another –Xassem-extdirs path that contained the XNA assemblies (and mscorlib.) My compile looks like:

<Scala.Net directory>\bin\scalacompiler.exe 
–target:msil 
–Xassem-extdirs <Scala.Net directory>\bin
-Xassem-extdirs <directory with XNA assemblies>
-Xshow-class <Scala class with main defined>
-Xassem-name <Name of MSIL file to output>
<scala files>

After running ilasm on the MSIL file generated, corflags needs to be run on the resulting executable to put it into 32 bit mode. Running the executable opens the game window.

This is certainly a proof of concept; unfortunately that is as far as I could reasonably get. Miguel seems committed to getting Generics support in Scala.Net, so it should be possible to build a full game soon.

This entry was posted in .Net, Scala, XNA. Bookmark the permalink.