Microsoft Developer Day at Hull College

Category : Microsoft · No Comments · by Jun 14th, 2013
Microsoft Developer Day at Hull College

We had a great time over at Hull Collage last week. Josh, Lee and myself went to give a talk…

Three Thing Game June 2013

Category : Games · No Comments · by Jun 5th, 2013
Three Thing Game June 2013

Three Thing Game is a “semesterly” event at Hull University run by Rob Miles. It’s a great opportunity to get…

TTG Side Competition: Win a Kinect!

Category : Uncategorized · (1) Comment · by May 28th, 2013

It’s that time of year again where we consume copious amounts of energy drink and pizza while creating some great games in 24 hours. This semester’s Three Thing Game is looking great, with guests from Boss Alien coming up to compete and what will surely be an excellent selection of new words. I can’t wait!
TTG Side CompetitionYour friendly neighborhood Windows 8 Games ambassadors, Josh Naylor and myself, have managed to wrangle a set of four Kinect Sensors for one lucky team. All you have to do is develop your game for either the Windows 8 or Windows Phone 8 stores and get them published by 20th June. Register your game here. The winning team will be judged by a panel of Microsoft employees and the winner will be announced on the 30th June. T&Cs. We will do our best to help anyone publishing to Windows 8 or Windows 8 Phone, so if you need a hand just let us know!

There are some brilliant tools available to develop for windows platforms. MonoGame is an Open Source implementation of the Microsoft XNA 4 Framework. This allows you to deploy apps across a wide variety of devices with a huge amount of code reuse. They currently support MacOS, Linux, iOS, Android, PlayStation Mobile and OUYA. Have a look at some of the games currently using MonoGame over at MonoGame.net.

MicrosoftLogo

Windows 8 App Builder Rewards

Category : Microsoft · No Comments · by May 24th, 2013
Windows 8 App Builder Rewards

I recently took part in a rewards program run by Microsoft called App Builder Rewards. The aim was to produce games and…

Modern Jago Event

Category : Games · No Comments · by Apr 13th, 2013
Modern Jago Event

Myself and the other 16 Windows Games ambassadors were invited down to London again this weekend to learn all about…

Student Project Survey

Category : Games · No Comments · by Feb 21st, 2013
Student Project Survey

As part of our roles as Windows Games Ambassadors, Josh and myself have decided tocreate a survey to find out just…

TerraTouch – Gravity at your Fingertips!

Category : Games · (4) Comments · by Feb 3rd, 2013
TerraTouch – Gravity at your Fingertips!

TerraTouch is an exciting new space-puzzle game soon to be released on the Windows 8 App Store. An atomic experiment…

Resolution is Futile: Simple XNA resolution independence

Category : Games · (4) Comments · by Feb 1st, 2013

One great thing I found about the Windows Phone 7 platform as both a developer and user, is the consistency of the hardware. If you develop a game for one handset, it is more than likely going to run fine on all other makes/models. This made it great for a newbie game developer as I did not need to cater for different resolutions and hardware specifications. If it ran smoothly in 480×800 on my Lumia, I was fairly confident it would work on anything. However, after moving onto Windows 8 and multi-platform development I have had to come up with a way to implement resolution independence in my code.

For a game with no fixed viewport, where a camera is defined independently from game-play mechanics it is easy to handle different resolutions by merely having more of the game in view. However, if the play area is intended to be the full size of the screen, changing the resolution can have more direct implications on how sprites are arranged and moved.

In the case of TerraTouch, I have defined the play area as the visible screen, and the player will never move away from this. This means that no matter what resolution the game is played in, this area must still be in view and the objects on screen must be in the correct locations.

Virtual Resolution

Firstly, we need to set a virtual resolution. This is the screen size that we will base the rest of our game on. I have chosen 1920x 1080 as this is my PC’s native resolution and is easy to work with. We then need to define a “Scaling Factor”. This will be calculated later to show the ratio between our virtual resolution and the actual resolution of the deployed device.

//Resolution Independence
Vector2 virtualScreen = new Vector2(1920, 1080);
Vector3 ScalingFactor;
Matrix Scale;

Calculate Scaling Factor

In this example I have decided to calculate ScalingFactor every update, so that the game automatically scales to the new resolution. In the Update() method of our game we need to calculate our ScalingFactor using our virtual and actual screen dimensions. The ratio is determined by dividing the real resolution by our virtual resolution.

//Calculate ScalingFactor
float widthScale = (float)GraphicsDevice.PresentationParameters.BackBufferWidth / virtualScreen.X; 
float heightScale = (float)GraphicsDevice.PresentationParameters.BackBufferHeight / virtualScreen.Y;
ScalingFactor = new Vector3(widthScaling, heightScaling, 1);
Scale = Matrix.CreateScale(ScalingFactor);

Draw

Now all we need to do is draw our spriteBatch using this scaling matrix. In our Draw() method, we need to replace spriteBatch.Begin() with an overloading method that includes a  scaling matrix.

//Draw using Scale Matrix
_spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null,null, Scale);

If you deploy and run the game everything which is being drawn in that spriteBatch should be resolution independent as the below image clearly shows. This image also highlights a problem with this method. When the game is run in a different aspect ratio, objects on the screen appear stretched. A letter box/ pillar box system could be added to this method to avoid this problem, while sacrificing usable screen space. As it is fairly uncommon for mobile devices to not use widescreen aspect ratios and I am under a tight deadline I have not included this.

XNA resolution independence

Touch Input

Another problem you may encounter is a miss alignment when it comes to touch input. Everything is drawn and positioned on the screen according to the virtual resolution that has been set(in my case 1920×1080). However, touch input is still calculated using the actual resolution of the device. Below shows how the Actual and Virtual resolutions are miss-aligned on a 1024×768 device.

XNA resolution independence

To remedy this, I have used our ScalingFactor vector to transform all of input points to be inline with our virtual resolution. Dividing the real touch point vector by our scaling factor, gives the position on our virtual screen.

//Transform touch input
for (int i = 0; i < touchCollection.Count; i++)
                {
                    InputPoints.Add(new Vector2(touchCollection[i].Position.X / Game1.ScalingFactor.X, touchCollection[i].Position.Y / Game1.ScalingFactor.Y));
                }

Summary

Obviously this is not the best way of implementing resolution independence as it does not handle different aspect ratios, but it has worked well for me so far. The method you choose to use is ultimately determined by the kind of game you are creating and your intended target devices. I have used it in both TerraTouch and Heart Attack across a variety of desktop and mobile devices. As I have previously mentioned, the Windows 8 Simulator is a great tool for debugging resolution problems and MonoGame can be used to deploy to other mobile devices such as Android and iOS.

Feel free to comment and rip my code to pieces!

2nd Place at Global Game Jam Hull

Category : Games · (2) Comments · by Jan 28th, 2013
2nd Place at Global Game Jam Hull

After 48 hours of development and a good night’s sleep I’m ready to write about my fist experience of Global…

Want to develop for Win8 but don’t have the hardware?

Category : Games · (3) Comments · by Jan 25th, 2013
Want to develop for Win8 but don’t have the hardware?

I have been working on TerraTouch for Win8 a fair bit over the past week but haven’t been able to truly experience…