Microsoft Azure WebJobs in Truck Trials

In my latest game Truck Trials (read the Making of Guide) I’m running a special championship every weekend, named Weekend Champion Cup.

To get this cup started I need to do some simple things in the database:
1 – Friday at 17:00 GMT, Reset the data from the previous competition
2 – Friday at 18:00 GMT, Start the competition
3 – Sunday at 18:00 GMT, End the competition
4 – Sunday at 18:30 GMT, Award the winner

In the early days of this project, I did this manually because I had to prioritize other development tasks. But this meant that I had to make sure this was done every Friday evening, and stress about this during dinner or at a get together with the guys – and the same every Sunday.

Now this has change since Azure WebJobs is doing all of this for me!

It’s very simple – just create a Console application, zip it and upload it to a WebJob on your Azure Web Site project. When creating the WebJob, you can specify to run the application continuously or at a schedule.


The implementation

Developing the Console App:
First of all, you need to develop the console app that will execute the task you want to perform.
To do this, start Visual Studio 2013 and create a new Console project (I used C#). In my case, I added the EntityFramework NuGet package since I was going to do some operations on the games database.


This Solution contains all of my WebJobs, one project pr. job I want to perform. In this post, I’m just going to focus on step 1, resetting the players score. All other steps are implemented in the same way.

So basically, this is what this application does:

It starts a Stopwatch (nice to track the time of the operation), resets the scores and writes the output to the Console.

The cool thing here is that all output from the Console app is displayed on the WebJobs management page, so I can simply just log in to the Microsoft Azure portal, and see the results there. More on this soon!

Now that the console app is done, it’s time to create the Web Job. First of all, we need to ZIP the program. This will then be uploaded as the WebJob package:



Creating the Web Job
Let’s make the cool stuff happen!

1. Log in to Microsoft Azure, go to your Azure Web Site project and click Web Jobs:

2. Click Add


3. Fill out the information on page 1 and click next

4. Fill out in the information on page 2 and click next


5. Wait for the WebJob upload to complete

6. Test it by clicking RUN ONCE:


Checking the output

The cool thing about this is that you can check the console output. Just click the LOGS link on your WebJob.

You will be redirected to the WebJobs page on Microsoft Azure, where you can see a list of web jobs, status and how long time it has gone since it was last run:

By clicking the WebJob, you can dive in to the details, and also see the console output:


And that’s it, you got a WebJob up and running, doing critical tasks for you Smile 

Thanks to Pedro Dias for helping me with this!

Posted in Azure, Truck Trials, Tutorial | 1 Comment

Video Tutorial: Creating a Flappy Bird type game using Unity 4.6

Today I had a webinar named “Developing Games for Windows”, it’s one of my first recordings but I hope to create many more with better quality going forward.

Anyways, I decided to share what I made in case any of you would find it useful.


The goal here is to share how to create a simple game using Unity 4.6, and how to export this as a Windows Store app, and as a Universal App that targets both Windows 8.1 and Windows Phone 8.1

In this post, I want to share the video, and provide you with the source so you can create your own games, and help you publish it to the stores! Smile

I) Check out the video
II) Download the source, create your own version
III) Publish
IV) Check out my “Making of” guides so you can learn how this looks in the bigger picture

I) Learn the basics of Unity by creating another Flappy Bird clone


II) Source
Feel free to use the source however you like, and even reuse the graphics.

Download source

The source contains the Unity Project of the game, the Windows Store export, and the Universal export of the game.

Modify the game as you like, make your changes, try to change the graphics and learn from the process.

Once you have created your own version of the game, go ahead and publish it – and learn from it. You gain a lot of knowledge by just reading the download data, making modifications to the app tagging to see if it increases or decreases download rates and so on.

Note: Make sure you have the latest update for Visual Studio 2014 (Update 4) before you open the Universal export.


III) Publish
I made this simple guide on how to export and publish a Universal app


IV) My “making of” guides
I have created a few games, and for each one of them I created a “Making of” guide explaining how I did it. Click the image of the one you wish to read. Smile

The Making of Truck Trials

The Making of Starcomet Online

The Making of Bandinos

The Making of Binary Man
Binary Man

Posted in Tutorial, Unity, Windows 8, Windows Phone | 2 Comments

The Making of Truck Trials–Multiplayer Racing

Truck Trials - Multiplayer Race skjermbilde 0

Project Truck Trials started back in June 2014, after Starcomet 2 was released. And as usual, with every game release I do comes a making of guide, just to share the process and what I did to end up with the result I have.

Read my other guides


The game takes you to a trial track where you have to maneuver a heavy truck through harsh environment, hills and jumps as fast as you can – or at least faster than your competitor! You are free to design and change the look of your truck, change your name and play both in Time Trial and online 1 vs. 1 race.

Try it out:

image image[8]

The game logo is inspired from the American interstate road signs, with a truck grill and mirrors to make it look a bit like a truck, but at the same time have similarities to the NBA, NASCAR, NHL, MLB, NFL++ logos.

left-43868_640 image

It’s a connected game, so you need to be connected to the internet to be able to play. An account will be created for you when you first start the game – using the GUID of your Microsoft Account.


30 tonnes, 200 km/h, 20 meters up in the air, welcome to Truck Trials, a high pace, side scrolling physics based racing game!

Create, design, and race a heavy truck against random players in the biggest truck trial racing tournament ever!
 Truck Trials - Multiplayer Race skjermbilde 3

Unlock truck parts, put them together and give them a color to create a truck that fits your style! The top three players will see their design nicely lined up on the throne in the ranking screen!

Play against random players, win and earn credits, and become the ultimate truck racing champion!Truck Trials - Multiplayer Race skjermbilde 2

Race against time! Can you beat your personal record?Truck Trials - Multiplayer Race skjermbilde 6




Truck Trials - Multiplayer Race skjermbilde 1
Back in December 2013, my brother and I attended some Hackathons, where we were put up to a challenge to create and implement a game idea over a weekend.

We took this concept to a cottage up on the Norwegian mountains for a weekend where our goal was: “Let’s create 10 games, where we use max 3 hours on each – then all of these prototypes must be good enough for publishing. If we exceed 3 hours, we scrap it.”

7 or our ideas was successfully published on a public Game Jam account, where we could follow the prototype when it comes to stats and downloads.

Two of them stood out with over 100.000 downloads in a short amount of time (and much more later). One of them would take too much time to implement, and the other was a truck game that looked like this:

So basically, we skipped paper prototyping – and instead created a digital game with proper stats, and feedback.



The game is made with Unity3d, a great game engine for creating all kinds of games and interactive experiences. We used this because of the good engine, and the great possibilities it has when it comes to exporting.


Truck Trials is a Universal App. It’s an app that runs on both Windows 8 and Windows Phone, and is connected on the store (basically, is shares everything, including IAP ++).

imageFor the multiplayer part, Photon by Exit Games is used for real-time communication, and Microsoft Azure for all of the services and database. Photon is used because it’s a mature and modern platform, that’s 100% integrated with Unity3d.

When it comes to Microsoft Azure, all of the logic is created trough a custom Visual Studio DLL project that’s used as a plugin with Unity. I had to write one plugin for Windows 8.1 and one for Windows Phone. Most code could be reused, but I needed some custom stuff that’s platform dependent. Prime31 also got some plugins for Azure, so be sure to check them out!


I’m very satisfied with how fast and easy it was to create the services I needed, and how much flexibility I had when setting them up (scale, performance).

What I have online is a couple of services, a web site, a mobile service and a database that connects all the logic together.

There are a lot of different ways to implement all of this, but this was my choice based on earlier experiences. Most of the communication is through REST/Web Services, while the real-time positioning is peer to peer using photon.

The awesome thing about making stuff with Microsoft Azure is the nice user interface to the platform. I can track everything that happens on the server, and see exactly how my queries are performing, how much data is being used and so on.





I started working on the game in June and the core of the game was developed before going on summer vacation. After that there has mostly been content creation, level design and polish – and with very little time on my hands to actually work on this game, it took a while to get it “done”.

I made sure to have a a beta version available from the start so people could try the game, give me some feedback, and post updates to a dedicated beta testing group on Facebook.clip_image002

The first iteration of the game was a simple straight line where one could drive a box with wheels. The box was the truck, and the wheels was the physics system – this was to create the balance, get the correct forces and the feeling I wanted to have. I spent a lot of time playing with different gravity values, to get the “Heavy Truck” feeling. Then I changed the box to a proper model and worked on the scale.

Next was to get the multiplayer part working, so one could see the other player on the same track, set up the correct cameras and make it playable with two players (and get the winner).

clip_image002[5]Once the mechanics was in order, I started to create the first iteration of the menu systems and the truck customization to be able to create the internal logic that renders the customization, stores it to the server, sets the correct colors and basically defining the rules I needed to follow.

Then I started the modeling process on some real trucks and truck parts, and do the level designs on a few levels just to get it started, and see how the mechanics work in a “real” scenario.


I also created the online services that connects everything to a user account, and the plugins that connects the client to the server, and the IAP system.

Most of the game is straight forward and pretty easy to implement, but there are a couple of features I want to highlight.

Here you can see the iterations of the user interface from start to finish:


I recommend you to create and test a protoype of your interface, and work with it. It takes a lot of time to totally re-implement the UI like I did in this game, but don’t be afraid to re-implement it – it will be worth it!



The challenges system was fun to create. After the initial launch of the game I needed to increase the retention rate of my players. So I decided to add a couple of things to do this, and one of them was to add a system that tracks what you do, and give you a reward if you do enough of it.

What’s behind it?
– two database tables that store the data online
– a couple of web services that handles incoming and outgoing data
– a client function that makes progress of a challenge, and one that gets the status of all active challenges.

The challenges system consists of a few tables that is hosted on Microsoft Azure. One is the challenge description itself, and another one is the tracking of a challenge pr. player.


When the player is checking the Challenges status, the client requests the current active challenges from the cloud, gets a reply and renders them.

When the player is completing an interesting activity in the game, like winning a race, loosing a race, buying anything, or simply just completing a race, a function will notify what the player just did, and then the server will do the rest – like checking if it’s true, then handling the updates for all the challenges that are affected by that activity.

The Progress function will also reply to the client if this new progress has made a challenge complete. If so, the reward is added to the account.

Christmas Special Challenge
In addition, I created a special challenge that’s only available during Christmas (but the function can be reused whenever, like Easter, Halloween, summer and so on). This challenge counts the number of challenges the player has completed, and if it meets a certain goal, an item is unlocked for the player.


For this challenge, I unlock a Christmas-special badge and emblem, and enough truck credits to buy a Christmas hat – just to set the mood. Smile

The main menu has also been changed to have a darker blue background, with snow and the northern light – it’s Christmas. Open-mouthed smile



I wanted to test out ads in a game, so I simply used the Prime31 plugins for Microsoft Advertisements (AdMob is also available for Windows Phone).

Before you can start using ads, you will need to register an account at all of the different Ad providers you want to use.

1. Register at Microsoft Advertisement:
2. Register at Google AdMob:
3. …..

Once you have registered here, you are able to create an ad, get the ad ID and then simply using those keys in the Prime31 plugin. The rest is automatic! Smile



The weekend champion cup is a cup that starts every Friday at 18:00 and ends Sunday at 18:00 (GMT). It’s the same type of racing as before, but in addition to getting the normal stats, you also get championship points – and every weekend, I reset the existing championship points to 0, so everybody starts at the same page for every weekend.

These points are used in a dedicated ranking podium that the players can see in the ranking screen. Again, everyone starts from scratch, and the winner gets 2000 Truck Credits to spend on any truck parts they wish, and a unique Champions Cup badge and emblem that they can use to show off to their competitors that they won.

In addition, all the winners are posted on the games Facebook and Twitter page:

This implementation is very simple. It just checks if the server says that the compo is active, and if it is – it changes the normal Race Online button to another button that takes you to the Weekend Champion Cup. The rest of the race is identical to the others.



The badge system is a way for players to show other players what they have achieved. The Badges can only be unlocked by meeting certain criteria like being a game tester, the developer, completing the Christmas challenge, buying a Premium Account, spending real money on the game, winning the Weekend Champion Cup and so on.

A badge is using the same system as the other parts of the truck, but in addition, the lookup id of a badge item (read more on the below) is used to also change the emblem that will appear below your nick when starting a race.



The game features a Premium Account that can be bought as an IAP. If you got a Premium Account, you will get 100% extra in-game truck credits earnings for every match you play, free color painting, access to the Rim Editor, as well as unlocking the Premium Account badge and emblem, 1st person view and a donator badge/emblem (this is unlock to everyone who spends money on the game).

This is a simple implementation. If you buy the Premium Account IAP (durable), the features will be enabled. It’s simply a function that checks the IAP, and then your account – and if everything is OK, it will unlock the items in the database.

The 1st person view is implemented by having two cameras on the trucks, and then using unity logic to enable/disable the correct cameras based on a setting from the Settings menu. Each camera has a rendering layer, so I can specify what the 1st person camera can see, and what it can’t – to hide items like the Christmas hat.

In addition, when playing 1st person, the normal view is displayed in the corner in-case you need to get out of the truck and get a proper reference – just as an aid.





The game uses ID’s to select what items it should render where. One truck is put together by 5 factors:
– Chassis
– Exhaust
– Roof
– Rear
– Badge/Emblem

These items are just an integer that is stored on the player profile, and used as a lookup in the items folder. The system then assembles the car by using the lookup IDs to find the correct prefab, and then Instansiating them in the right place on the truck.

Each chassis contains points of interest, like an empty game object where the roof should be, another where the rear should be and so on – this is spesific pr. car, since the positioning is quite different on each of them.

This chain of ID’s is then communicated between the players you race against, and then built up locally the same way.


NEW+RISING: When publishing the game, it will stay on the “NEW+RISING” list for some weeks. Make sure your game is as finished as possible before it reaches this list. In my experience it usually takes about a week to get there, so you got a few days to test and make sure the published version is working as it should. These first weeks will be very important going forward.

KEYWORDS: When publishing, you can type in some search keywords. Change and test these frequently if you don’t get any downloads. Changing this can multiply your download rates.

ADS: Make sure you have a good fill rate, and a good eCPM. Test your ads at different places, and make sure it wont overlap anything of importance on the screen. Test with different screen resolutions, and orientations.


It’s free to download, so if you appreciate this guide, please help me by testing the game and by giving me a rating – and/or an e-mail to with feedback. Smile

image image[8]



A special thanks to Thomas for helping me when needed, to Tuuli for support and my brothers Olav and Paul for testing.

Also, thanks to all the testers in the Beta Program – more versions are on the way, so be ready! Smile

Posted in Uncategorized | 4 Comments

Truck Trials Update: Daily Challenges, Top 50 Players, 1st Person View, Badges, Trick Boost, Stats and much more!

The latest version of Truck Trials has been published on both Windows Phone Store and Windows Store, with a lot of new neat updates for you to enjoy!

This update brings a lot of news, features and functions.

So, what’s new in this update?
– Challenges
– Top 50 list
– Better results screen
– Badges and Emblems for your truck and name
– Trick boost
– Stats on the main menu
– Premium Account
– 1st person view (for Premium Accounts)
– A lot of bug fixes and polish

image image[8]

Here is a bit more information about each feature:

Mostly daily, but also long term challenges has been added to the game. These challenges will progress automatically, and when you complete it, you will get the reward straight to your player account.

Playing many dailies will also unlock special features like unique badges and emblems for show off towards your rivals.



Global top 50 players list
This feature has been awaited by many, but now you can finally see your own ranking even if you’re not on the top 3 list, or in the top 50 list. Also, the top 50 players list has been added so you can see how much points you need to get on the list, and how much the players ahead of you are leading!


Better results screen
The results screen has got a bit better with a nice litte trophy, a standing list, and icons that show how much you gained after a race.


Badges & Emblems
These special items are not buyable with Truck Credits. They are unlocked of you do something special. One is to be the developer of the game (the golden eagle you can see in the picture below), other is a silver eagle that all testers of the game gets. But also there is many badges that can be unlocked by doing stuff in game like by winning the Weekend Champions Cup, you will get a nice trophy badge and a name embelm so that all your rivals you race against can see that you have previously won the Cup Trophy!

Others are if you spend money on the game you can get the Donator and Investor badge, if you complete all time trial levels with a 3-star rating, unlocking the premium account and so on. You can change between all your unlocked badges in the Garage.image


Trick Boost
Do tricks with your truck for a chance to get a speed boost. This can be a great front flip or a back flip. Remember, you have to land your trick to get the boost!


Stats on main menu
Now you can get direct feedback on how you are performing directly form the start menu. These icons show if you have a premium account or not, your current global ranking, your win rate, and your current time trial rating.

New icons below your driver name.

Time Trial stat shows how many time trial shields you have been able to gather in total.


Premium Account
Premium account unlocks a unique premium account badge, the donator badge, gives you 100% extra truck credits when completing a race, removes ads, and also unlocks the 1st person camera view!



1st person view


You can enable 1st person view from the settings menu after unlocking the premium account.

Posted in Game programming, Racing, Truck Trials, Windows 8, Windows Phone | Leave a comment

Developing Universal Apps for Windows 8 and Windows Phone 8 using Unity3d

1. Introduction
The amount of quality apps and games on both Windows and Windows Phone is rapidly increasing, and the similarity between the platforms when it comes to development is marginal. Creating a Windows 8.1 app or game, and then porting it to Windows Phone 8.1 is usually a small task.

2. What is Universal apps
Universal app is a project type that enables you to create an app once that shares code, and generates an app packaged for both Windows Store and Windows Phone Store – as a result from the Windows platform convergence movement. This doesn’t mean that there is a magic button that just creates a package for the other platform – since you still need to account for the different form factors, handle certain launchers that only makes sense on a mobile device and so on.

But we are at a level where most of the function calls of the SDKs are similar, they share the revenue model, installs across devices, shares the in-app purchases, got the same pricing structure, will get linked in the store. If you buy the app on a Windows Phone, it will also be available on the Windows Store.


As you can see in the screenshot above, there is a small text below the game pictures, on the right side:

Unity3d ( exports Universal Apps for FREE (no need to have a PRO license) – as I did with my game Truck Trials. And in this tutorials, I will show you the steps required to export and find the packages.

You can read more about Universal Apps here:

3. Exporting
Using Unity3d, exporting is very simple. In your unity game project, go to the export

When you export the Universal App, it will generate a Visual Studio Solution that contains three projects. One for Windows, one for Windows Phone and one Shared project that contains logic that is shared between both platforms.

You can then build and generate the app packages from the Visual Studio solution. One will be fore Windows Phone 8.1 (ARM), and another for Windows 8.1 (ARM and x86).


4. Publishing

Follow these great guides for a step-by-step guide to publish your app.

Windows 8:

Windows Phone 8:

Posted in Tutorial, Windows 8, Windows Phone | 2 Comments

Truck Trials released for Windows 8.1 and Windows Phone 8


My latest game for Windows 8.1 and Windows Phone 8 is released, and can be downloaded for free here:
image image

The game takes you to a trial track where you have to maneouver a heavy truck through harsh environment, hills and jumps as fast as you can! You are free to design and change the look of your truck, change your name and play both in Time Trial and online 1 vs 1 race.

I got the inspiration for the logo from the american interstate road signs, and added a truck grill and mirrors to make it look a bit like a truck, but at the same time have similar looks to the NBA, NASCAR, NHL, MLB, NFL++ logos.

left-43868_640 image

It’s a connected game, so you need to be connected to the internet to be able to play. An account will be created for you when you first start the game.


30 tonnes, 200 km/h, 20 meters up in the air, welcome to Truck Trials, a high pace, side scrolling physics based racing game!

Create, design, and race a heavy truck against random players in the biggest truck trial racing tournament ever!

Unlock truck parts, put them together and give them a color to create a truck that fits your style! The top three players will see their design nicely lined up on the throne in the ranking screen!

Play against random players, win and earn credits, and become the ultimate truck racing champion!

Race against time! Can you beat your personal record?

The game requires internet connection. When playing for the first time, an account will be created for you.

TOUCH: Tilt your truck by touching on the left side of the screen, accelerate/break/reverse with gas pedal.

KEYBOARD: Accelerate with W, break/reverse with S, and tilt the truck with A and D – or use the same set up but with the arrow keys.

image image

Posted in Uncategorized | Leave a comment

Support Norse Noir: Loki’s Exile, a classical point ’n click adventure game on Kickstarter!


Some of the guys behind awesome games such as Anarchy Online, Pets vs. Monsters, The Secret World, My Kingdom++ has gone live with a classic style, hand-drawn adventure game (hence Day of the Tentacles, Kingdoms Quest, Sam & Max, Indiana Jones) on Kickstarter.

Being a big fan of these types of games, I found it right to spread the word to help them make this project a reality. I really want to play this game and see what’s behind this strange setting of a story.

It seems like the game takes place in what looks like the typical American 20s, with art that gives me the good old adventure game feeling – and it seems to include magic, what more can I ask for?

We need more classical adventure games, so if you are an adventure game fan like me, you should help them by supporting them on Kickstarter:



The Story (copied from Kickstarter):

In Norse Noir: Loki’s Exile, players take on the role of one Lars Kristiansen, an immigrant from Norway to the United States who is facing rough times. Once a low-level courier for the local mafia famed for his amazing luck, Lars is now relegated to making money as best he can as a street magician, offering shows three times weekly at the local watering hole The Cold Trout. After a sudden change of leadership in the local racket Lars has found himself scraping lately to make ends meet… ends that may be coming a lot sooner than expected.

In-game screenshot In-game screenshot

Our story opens with Lars in dire straits, tied to a chair in the back room of the local pawn shop and staring down an angry mobster with a chip on his shoulder and bat in hand – Apparently he’s missed a few too many payments on an outstanding loan he owns, and the mafia is ready to collect. After a brief encounter with the lethal Swahn sisters, current overseers of the city’s underbelly, Lars is given only a few days to scrape together the rest of the money he owes, or it could be curtains.

In his quest for cash, Lars quickly stumbles across a series of events that leave him questioning himself, his friends, and even the very nature of reality itself. With muscle-bound mooks breathing down his neck and a mysterious pendant that seems to be making him public enemy number one, Lars is going to have to do some quick thinking, fast talking and probably some swift running if he wants to make it through this adventure!

With a solid focus on fun, humorous writing, Loki’s Exile aims to be a family-friendly adventure title that appeals to all ages.


Posted in Uncategorized | Leave a comment