Reputation: 26756
I know there's no VB.Net project type for the XNA games but as a simple test, I threw together a VB Solution which references Microsoft.XNA.*
. It has a class which implements Microsoft.XNA.Framework.Game
. Then in the C# Game1.cs
, I simply removed all the boilerplate code and modified it to inherit from my VB class...
namespace MyGame {
public class Game1 : GameEngine.Engine {
}
}
Which is inheriting...
Public Class Engine
Inherits Microsoft.Xna.Framework.Game
Protected Overrides Sub Update(GameTime As Microsoft.Xna.Framework.GameTime)
If GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed Then
Me.Exit()
End If
For Each Element In Elements
Element.Update(GameTime)
Next
MyBase.Update(GameTime)
End Sub
...
This seems to work and I've been able to load content, render a model, take gamepad input, etc...
So what I'm asking is... Is there really a restriction due to some advanced features not supported in VB.Net or is it merely that no project templates/support are available?
Is there some performance optimisation when compiling to MSIL that the VB compiler misses?
Upvotes: 13
Views: 2763
Reputation: 1395
XNA does support VB. This was announced back in May of 2011 -> http://blogs.msdn.com/b/vbteam/archive/2011/05/25/vb-support-for-the-xna-platform.aspx
Upvotes: 8
Reputation: 28316
VB.NET and C# both compile to the same MSIL at a semantic level, so it's not a technical limitation. As you've seen, it's not too difficult to hack together a VB.NET app that accesses XNA.
The restriction is simply because examples have to be written in a particular language by a person, and most professional game developers will be coming from a C++ background. It's a human resource limitation - they can only write so much sample code.
There are also some performance differences between C# and VB.NET, which may have contributed to Microsoft's decision.
Update: It also turns out that VB.NET doesn't support unsafe code. You'll often find cases where unsafe code is necessary in games programming, for performance reasons. I have a feeling that Microsoft's decision was made based on a compound list of reasons.
Upvotes: 14