Comet Chaos First Showing

Category : Games, Programming · No Comments · by Nov 9th, 2013
Comet Chaos First Showing

I haven’t had a lot of time to update my blog lately, so I’ll be doing a lightning round of…

Presenting at Trinity Academy

Category : Games, Microsoft, Programming · (1) Comment · by Oct 21st, 2013
Presenting at Trinity Academy

I always wish that I had gotten into game dev earlier. At school we were never really pushed, there was…

Hull ComSoc 2013

Category : Games · No Comments · by Oct 10th, 2013

A6Comsoc FlyerLast year I was elected as secretary of the ComSoc exec team for 2013. This means that along with all the emailing and minute taking, I get to take a big part in promoting the society among the new freshers. We decided to try and generate a lot of hype at the societies fair and decided to borrow three xbox 360’s from Platform Studios. We also had 500 flyers printed out to hand out at the event. Our table had a crowd throughout the whole event and people were very impressed with the flyers. I’d love to thank Platform Expo for allowing us to borrow the Xbox’s and Hull University Union for putting on the event and providing us with some free pizzas!

Hull ComSoc 2013Following on from the Societies fair, we attended the Computer Science Fresher’s party along with Platform Studios to do a quick talk about the society and to setup a 10 Xbox LAN game of Gears of War. This was very well received and it was a great opportunity to meet the new students. After the party we decided to have our first un-official social at karaoke in the Union.

WP_20131002_003Yesterday was our first Fragfest of the year. We decided to make this a free event for people to attend before they paid to become a member of the society. So they could try it out and see if they liked us enough to pay their subs! Because of this we were expected a pretty big turn out and decided to run one big TF2 LAN game and a separate game of DOTA. We ended up having to swap people around pretty much every game and even had people waiting out in the corridor between games!WP_20131009_002

All in all this year is looking to be a really good one for the society and I can’t wait to see what’s in store for us. If your interested in joining, join our group on facebook!

EuroGamer 2013

Category : Games, Microsoft · No Comments · by Oct 8th, 2013
EuroGamer 2013

Last week myself and Josh went down to London for Eurogamer. It was a great opportunity to meet up with…

TeenTech Humber

Category : Education, Games · (1) Comment · by Jul 24th, 2013
TeenTech Humber

A couple of weeks ago we had the pleasure of helping Simon Grey out at TeenTech Humber. TeenTech is a…

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…

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);


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));


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!