1) Create an empty VB 2005 project.
2) Add references to
Microsoft.Xna.Framework
and Microsoft.Xna.Framework.Game
. Both should be in the GAC.3) Add a module named Program.vb.
Code:
Module Program4) Add a class named Game.vb.
Sub Main()
Using game As New Game
game.Run()
End Using
End Sub
End Module
Code:
Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Audio
Imports Microsoft.Xna.Framework.Components
Imports Microsoft.Xna.Framework.Graphics
Imports Microsoft.Xna.Framework.Input
Imports Microsoft.Xna.Framework.Storage
Public Class Game
Inherits Microsoft.Xna.Framework.Game
Dim graphics As Components.GraphicsComponent
Private Sub InitializeComponent()
graphics = New Components.GraphicsComponent
GameComponents.Add(graphics)
End Sub
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Sub Update()
' The time since Update was called last
Dim elapsed As Double = ElapsedTime.TotalSeconds
' TODO: Add your game logic here
' Let the GameComponents update
UpdateComponents()
End Sub
Protected Overrides Sub Draw()
If Not graphics.EnsureDevice Then Return
graphics.GraphicsDevice.Clear(Color.CornflowerBlue)
graphics.GraphicsDevice.BeginScene()
' TODO: Add your drawing code here
' Let the GameComponents draw
DrawComponents()
graphics.GraphicsDevice.EndScene()
graphics.GraphicsDevice.Present()
End Sub
End Class
There. You now have a functioning XNA game skeleton.
1 comment:
I haven't jumped on the XNA Express bandwagon yet, but judging from the vb code, it looks like all you have to write is some graphics code and game logic code. Couldn't be that bad, I say!
How robust are the XNA libraries?
Post a Comment