• Dizzy Dalek at NDC 2014

    The video of my talk on MonoGame and 3D (featuring a dizzy dalek) is now live on Vimeo:

    You can find the demo code on GitHub.

    Other NDC Game Development Related talks

    If you enjoyed this talk, you may also enjoy:

    Cross-platform physics-based gaming using MonoGame and Farseer

    Game and Simulator Physics for Developers, Gamers and Petrol Heads

    Porting Quake III to F#: A Journey to Functional Programming

  • Putting iAds in a MonoGame game

    Here is the code you need to add to Main.cs in you game to get iAds working. You don't need to add any unique IDs. The iAd SDK is able to work out what you app is by magic. Everything will work fine as long as your app is registered for iAds in iTunes Connect.

    I call the method SetupAdvert at the end of FinishedLaunching in Main.cs:

    private object _adBannerView;

    private bool _advertPausedGame;

    private void SetupAdvert()

    {

    int width, height;

    var view = (game.Services.GetService(typeof(UIViewController)) as UIViewController).View;

    if (view.Bounds.Width <= 320)

    { …

  • Real readonly lists in C#

    In C# there is the readonly keyword that enforced the rule that the variable must be initialised as it's declared or in the constructor. This works as expected for simple types, but for objects and lists it's not quite like that. With a list, you can still add, remove and change items in the list. You may also expose a list as a property with a public get and a private set. You want the owner class to be able to modify the list items, but you don't want anything outside the class to modify the list items.

    Here is an example with an almost readonly list, but as you can see it's not as readonly …

  • Custom XML model binder for ASP.NET MVC

    In an earlier post I wrote about using an XML value provider to allow you to send XML to your .NET MVC action methods. This is great, until you want to accept XML where you have a model that needs XML attributes to control how it's deserialized. As the value provider stage happens before model binding it has no knowledge of the model objects that the values will be pushed into. So it can't look at your model class's XML attributes.

    In cases like this, you're better of using a custom XML model binder.

    To setup an XML model binder you need to create a model binder and a model binder provider. …

  • Sending XML to an ASP.NET MVC Action Method Argument

    I read a great article recently by Phil Haack on sending JSON to an action method. This was very timely as I wanted to do exactly that in the REST API I've been creating for Kensei, a video hosting website. However, I wanted to make it work with XML as well as JSON.

    Phil Haack creates something called a JSON value provider, so I followed his example and created an XML value provider. I've used it on two projects now and it's worked a treat. I thought I'd share it with the world in the hope that it will be useful to others.

    Source code

    XML Value Provider (C# source)

    To get this working in your …