I am just beginning with this Mono and .NET stuff, and after reading a bit about F#, I decided to try to follow this simple game tutorial on F# and MonoGame:
http://bruinbrown.wordpress.com/2013/10/06/making-a-platformer-in-f-with-monogame/
After sorting out the many syntax errors of the code I copy-pasted from the blog, I got this code:
module desnovro
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Graphics
type Game1 () as x =
inherit Game()
do x.Content.RootDirectory <- "Content"
let graphics = new GraphicsDeviceManager(x)
let mutable spriteBatch = Unchecked.defaultof<SpriteBatch>
override x.Initialize() =
do spriteBatch <- new SpriteBatch(x.GraphicsDevice)
do base.Initialize()
()
override x.LoadContent() =
()
override x.Update (gameTime) =
()
override x.Draw (gameTime) =
do x.GraphicsDevice.Clear Color.CornflowerBlue
()
[<EntryPoint>]
let main argv =
use g = new Game1()
g.Run()
printfn "Desnovro!!!"
0
In a MonoDevelop solution I created an F# project with references to:
- FSharp.Core
- System
- System.Core
- Tao.Sdl
- MonoGame.Framework.Linux
- OpenTK
I added the above file, named Program.fs
. I am able to successfully compile the project, but when I try to run it, I get the following exception:
Unhandled Exception: System.TypeLoadException: Could not load type 'Game1' from assembly 'game, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'Game1' from assembly 'game, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
My first attempt was to have the class definition and the main function in separated files (like in the tutorial), but got the same outcome. If I comment out the references to Game1
and g
in the main function, the program executes and prints my message "Desnovro!!!" successfully.
What is wrong and how to solve?
I am a complete beginner in this .NET stuff, but I thought that, since I knew Haskell and liked functional programming, it would be quick for me to pick up developing games with MonoGame and F#. I am using Ubuntu 13.10.