MonoGame, F# and Santa!

Sign in to queue

Description

Yeah, I know, Christmas is over and we've all put, or are putting, the decorations away, but that doesn't mean we can't prep for next year! Or enjoy a little F#, MonoGame development...

Tim Jones has shared a great tutorial on he created a holiday themed game, using F# and MonoGame. This is a long piece that does a great job of walking you through the entire process...

Make Santa Jump - Making an endless runner game in F# using MonoGame

image

image

For the last couple of months, I’ve been addicted to Make Them Jump, an awesome game for iOS (and Android). When Sergey Tihon asked for volunteers for the F# Advent Calendar, I knew I wanted to do something related to games, and I decided it would be fun to make a Santa-themed clone of Make Them Jump. Unlike some of the other #fsadvent entries, the code for this game is not particularly clever or advanced; but the end result is, hopefully, enjoyable.

Before we go any further, I recommend that you download the finished game from GitHub (download “MakeSantaJump.Windows.zip” to get the pre-built binaries) and try it out yourself. There are 5 difficulty levels; on the menu screen, press the number key corresponding to the difficulty. Then press the key in the top-left corner of each panel (Space, F, etc.), to make the corresponding Santa jump. Try to get as high a score as possible! ...

If you manage to score more than 0 on the highest difficulty level, you’re doing great ;) In keeping with the original, I’ve pitched the difficulty somewhere between “fiendish” and “nightmarish”.

Okay - now that you’ve (hopefully) played the game, you’ve got a good idea of what we’re going to build. We’re going to write the game from scratch, step by step, using MonoGame. Or put another way, we’re going to write the game from scratch, using only A HIGH LEVEL LIBRARY THAT DOES BASICALLY EVERYTHING FOR US.

If you haven’t worked with F# much or at all before - no problem. I’ll include all of the necessary code here, and we’ll work our way right from the beginning to the end.

Our whole game will be only 300-ish lines of F# source code. Let’s get started!

File > New > Project

I’ve made the assumption, for the purposes of this tutorial, that you’re using Windows. As I mention at the end of this post, the game should work without too many modifications on Mac and Linux, but for now, it will be easiest to follow along if you’re on Windows.

I’m also assuming, if you’re reading this, that you already have Visual Studio installed. If not, grab the free Visual Studio Community 2013 and install it.

...

Conclusion

That’s it! If you’ve made it this far, well done! You’ve made a complete 2D endless runner game, in ~300 lines of F# code. Okay, there’s a lot that could be added to it - sound, perhaps a parallax background, nicer looking menus - but it’s playable as it is, and, I hope you agree, quite fun!

I ran out of time to run the game on a Mac prior to posting this, but I hope to do that soon, and then write a follow-up post. I expect that it will work without too many changes on both Mac and Linux, which would be pretty cool. It should even work on iOS and Android, although you’d have to make some adjustments - you don’t want to use keyboard input on mobile devices :)

Let me know in the comments if you have any feedback on the content or style of this tutorial. I’ve enjoyed putting it together - any excuse to make a game!

(As I was preparing this game and blog post, a somewhat similar game, Rudolph Runner, appeared on Hacker News. Rudolph Runner is a lot prettier than my game, but I think Make Santa Jump has the edge when it comes to difficulty. I’m not sure if that’s a good thing���)

Happy jumping!

tgjones/make-santa-jump

Endless runner game written in F# using MonoGame

The Santa sprite, which is arguably the best part of the whole game, is from here: http://opengameart.org/content/santa-claus

Shout out to Casey for making it available for free, and for licencing it under the Creative Commons Attribution 3.0 licence.

Note: If when you do the first clone and build, the Nuget packages are restored but the compile still doesn't finish without errors (i.e. the References seem to still be empty), exit Visual Studio and start it and load the Solution (or unload/reload the Solution).

image



The Discussion

  • User profile image
    TimJones

    Thank you for posting this! Getting onto the Coding4Fun blog is a proud moment for me... :)

    Good point about restoring NuGet packages, I probably should have mentioned that in the blog post.

Add Your 2 Cents