Phillip Trelford's Array

POKE 36879,255

Building a game in a day

Last night I gave a talk at the F#unctional Londoners meetup about my experiences working in a team building a game in a day at the recent London GameCraft game jam event. We went with a continuous runner and used XNA to build the game on Windows with a hack to get it working on Visual Studio 2012, then Neil Danson was able to port it to iOS and Android using MonoGame. I brought along an Apple iPad and Google Nexus 7 both happily running the game.


iOS and Android

A recent article in the Guardian suggests that iOS and Android combined now generate four times the revenue of dedicated gaming handhelds. Both Unity and MonoGame let you target those platforms. I played a little with Unity at the Rezzed game jam early in the year, and MonoGame at GameCraft. As a coder by trade I felt more comfortable with MonoGame, where Unity can get you a long way fast but it felt more designer orientated (not necessarily a bad thing).

@ptrelford @qmcoetzee #theprismer on iPad from #gamecraft thanks #monogame!

Check out Neil’s article on F# and Monogame Part 4 – Content Pipeline

F#

At a recent QuakeCon conference veteran game developer John Carmack spent a chunk of his annual monologue extolling the virtues of functional programming. F# is a rich functional-first programming language with excellent imperative and OO features when you need them. The experience is similar to the Lua programming language, which is hugely popular in gaming, with it’s light syntax and all important coroutine support. Given that it can run cross platform I think it’s an interesting choice for Indie games development. The XBLA title Path of Go is a good example of what is possible. There’s also a book on F# game development Friendly F# (Fun with game programming).

Path to Go

Code Samples

Berzerk shows how to build a simple game AI using seq expressions:

let zombie target state = seq {
    yield! random_pause state 10
    while true do
        yield! wait target state 50.0
        yield! home target state 10
    }

Flint Eastwood is a small game I built in 6 hours at the first Dublin GameCraft event:

Flint Eastwood

Balls is a sound game, similar to Sound Drop I built last week:

Tsunami Balls

The Prismer is our entry to the London GameCraft game jam:

ThePrismer

New York, New York

If you’re interested in learning more about F# check out the Progressive F# Tutorials on 18th/19th in New York followed by a GameCraft game jam on Friday the 20th.

rev-progfsharpnyc-800x300px

F# on Android

Android games are now out-selling games for Sony and Nintendo handhelds. Thanks to the nice people at Xamarin you can now develop Android and iOS apps using all your favourite .Net languages:

Xamarin.Android 4.8.0 - New Features - F# support

Now it has been possible to target F# on Android and iOS for some time. In the latest release FSharp.Core is included and a blessed dll for the 64kb limit on trial versions.

Windows

You can use Xamarin.Android inside Visual Studio 2012 on Windows, which is how I got started. But I’d recommend giving Xamarin Studio a go, it has all the features you’d expect like intellisense and debugging.

Mac

In my opinion Xamarin Studio on Mac really whips the llamas ass!

On OS X you get a full suite of project options for Android:

full suite of F# projects in Xamarin Studio on Mac

And ASP.Net if that’s your thing:

ASP.Net from Xamarin Studio on Mac

There’s plenty of project options but there’s little in the way of WYSIWYG designers right now. That said F# is targeted more at code-orientated developers and I’ve rarely seen a developer use a designer for XAML, everyone seems to end up editing the XML directly.

Emulators

Once you’re up and running, which doesn’t take long, you can run your code at one of the supplied Android emulators or connect your device:

Xamarin Android emulator running on Mac

And of course you can debug live code running in the Android emulator:

Debug FSharp Code running on Android in Xamarin Studio on Mac

Nexus 7

Here’s my “hello world” bubbles app running on my Nexus 7:

Bubbles on Nexus 7

Tutorials

Neil Danson gave a great introduction to F# on iOS at Skills Matter recently:

Including a mini-game imaginatively titled Pissed Off Owls.

The experience for iOS and Android are pretty similar.

Neil also has a set of tutorials on F# and MonoGame:

If you’re interested in meeting the man behind Xamarin why not pop over to the Progressive F# Tutorials in New York on September 18th and 19th:

rev-progfsharpnyc-800x300px

Balls

While working on another game idea I bumped into a collision detection sample using the Processing language where you can draw walls for a ball to bounce off. It reminded me of SoundDrop on iOS. Here’s my own mashup using the collision detection code, Tomas Petricek’s reactive rectangles sample for the lines and a generated tremolo sound effect.


Along the way I found a “Chrome Experiment” version in JavaScript called BallsDropping and a very cute multi-level puzzle version created with Unity called drop.

I’ve put the code up on Bitbucket: https://bitbucket.org/ptrelford/balls

You can also edit and run the code as a script online in the Tsunami Cloud IDE:

Tsunami Balls 

Simply click the picture above to launch the Tsunami IDE with the script. Once loaded press CTRL+A to select the code, then hit the big green run button which will launch a window titled “Drawing”. You can then drag the drawing window out and dock it to the right or left of the code.

If you’re interested in learning more about games programming why not pop down to the F#unctional Londoners meetup this Thursday for a talk on building a game in a day.