F# With XNA Game Studio

Posted: April 5, 2011 in F#, Game Programming, Programming, XNA
Tags: ,

xna_logo

I’m currenly trying how to create XNA game with F# and the result is quite interesting :)  This experiment  was using Windows 7 x64, .NET 4.0, and XNA Game Studio 4.0

First step is creating F# Application using Visual Studio 2010

Then in your project expoler add references to XNA 4.0 libraries

Write code below in your Program.fs

open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input

type Game1() as this =
    inherit Game()
    let graphics = new GraphicsDeviceManager(this)

    let mutable spriteBatch = null
    let mutable texture = null

    override Game.LoadContent() =
        spriteBatch <- new SpriteBatch(this.GraphicsDevice)

    override Game.Update gameTime =
        base.Update gameTime

    override Game.Draw gameTime =
        this.GraphicsDevice.Clear(Color.CornflowerBlue)
        base.Draw gameTime

let g = new Game1()
try g.Run()
finally g.Dispose()

Already finished? Here’s the result when you run the program :

And… the result is ugly weird blue window :) since code above is just basic of XNA implementation in F# :)

Comments
  1. Have you taken it beyond the basic setup?

  2. […] page with description of options available from F#. On this page you can find a link to the “F# With XNA Game Studio” post by AzerDark (@azer89). In the post you can find the detailed guide of how to create a […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s