Supernova Particle System for MonoGame

Version 1.0 of Supernova Particle System for MonoGame now available!  Supernova makes it easy to setup particle effects in your games developed using MonoGame.  It was ported to run on MonoGame from my original XNA particle system on CodePlex.

This build initially targets Windows 8 and 2D game development only.  Further support for other platforms and 3D particle effects to come.

Now available on NuGet: https://nuget.org/packages/Supernova-Particle-System/
Source code available at: https://github.com/jasonmitchell/supernova

Use of SPContext.Current in SharePoint Code

First off, there’s nothing wrong with using SPContext.Current; this article is about using it correctly and structuring your code to work with it in a flexible way.

I worked on a fairly long running SharePoint project which liberally used SPContext.Current to access the SPWeb instance everywhere; it popped up not only in WebPart code but also business logic classes.  It’s perfectly acceptable to use SPContext.Current in your WebPart code-behind files because the context will be available in these places, however problems arise when your business logic classes make use of this singleton under the assumption that they will only ever be used in WebParts.  The moment you want to use these business logic classes anywhere else (think event receivers) things fall apart and you get exceptions when the code is called.

Continue reading

In-Memory Database Using Fluent NHibernate

When writing unit tests dealing with code that communicates with the database can be a pain.  All the information on Test Driven Development on the internet and in books always recommends that you avoid hitting the database.  Avoiding interacting with the database naturally has positive performance implications and has the additional advantage of not cluttering up a test database with a bunch of data created in our unit tests.  I’ve found that this lets me simplify my unit tests because I can make certain assumptions about the state of my data. There are different ways of avoiding interacting with a database but the two ways I have used are:

  •  Implement the Repository pattern and mock out the interfaces
  • Use an in-memory database

Continue reading

Using T4 Templates to Remove String References to ASP.NET MVC Actions

Ever since I started working with ASP.NET MVC there has been one thing that has bugged me a little bit; needing to reference my strongly-typed Controllers and Action methods by their string names.  It’s not a major problem for me but last night I decided to have a go at solving the problem for a project I’m currently working on.  There are the obvious simple solutions such as manually creating string constants or HtmlHelper and UrlHelper extension methods.  In the past I have used the extension method approach but frankly it’s a real pain to maintain going forward with updating names, removing methods, adding new methods etc.  In my opinion developers shouldn’t have to worry themselves with this kind of work when we can leave it up to the IDE (Visual Studio 2012 in this case) to do this monotonous work for us.

Thanks to Visual Studio tooling and C# language features such as reflection and extension methods I have created a basic solution that suffices for my project.  Note emphasised text; there is a possibility this solution may not meet your needs.  I am not trying to create a comprehensive copy-and-paste solution for this article, just sharing my work so far.

Continue reading

Using WinMerge with Git in Windows

Recently I’ve started using Git as my main source control system after several months of very vocally complaining about it.  I liked the idea of Git and distributed source control in theory but my limited practical experiences had been full of difficulties.  I figured this was simply due to me not really knowing how to work with it; turned out I was right.  After learning the basics I started to really enjoy using Git, so I decided to move a couple of my projects from SVN to Git and have never looked back since!  Now all my code is in Git.

Continue reading

Date Picker for C# & XAML Windows Store Apps

I found myself needing a date picker in the C# and XAML Windows Store app that I’m currently working on.  To my disappointment I found this control was available in the default controls for HTML and JS apps but not XAML.   I love XAML because it’s immensely powerful and flexible and I love being able to use it to develop apps for Windows 8 but the lack of equality in terms of availability of commonly required controls frustrates the crap out of me.

Update: I’ve set up my own NuGet package for this control so I can ensure it’s kept it up to date with the latest build.  You can find it at: https://nuget.org/packages/WinRT-DatePicker/

Continue reading

Microsoft XNA 4.0 Game Development Cookbook

Earlier this year I was asked to be a technical reviewer for a new XNA book called Microsoft XNA 4.0 Game Development Cookbook by Luke Drumm (Amazon); it is a problem-solution book covering quite a range of intermediate+ level topics.  The book mainly focusses on Windows projects however the author’s inclusion of solutions for XNA’s Reach and HiDef profiles (and the ease of reusing XNA code across Microsoft platforms) means that nearly all of the recipes are usable for Xbox and Windows Phone 7/7.5 projects.

Book contents (see Amazon for a more detailed table of contents):

  • Applying special effects; shadows, lens flare, smoke, explosions
  • 2D and 3D terrain; includes 2D isometric maps and Minecraft-style block terrain
  • Procedural Modeling; includes a nice recipe for procedural tree generation
  • Creating Water and Sky
  • Non-Player Characters; A*, state machines and dialogue
  • Animation; SkinnedEffect, Kinect and rag doll physics
  • Creating Vehicles
  • Receiving player input
  • Networking

Overall I think this is a useful book for intermediate+ developers interested in making games with XNA 4.0.

Theme Aware Panorama Control for Windows Phone

For the Windows Phone app that I’ve been working on recently I want to make sure that it has good support for both the light and dark themes on Windows Phone.  This is pretty easy to achieve in most places by binding styles to the built-in resources but I found myself needing to change the background image of a panorama control.

Continue reading