Peggit for Android

March 3rd, 2012 No Comments »

Finally I’ve finished it. Peggit is now available on Android, to compliment the versions on the iPhone and Windows Phone platforms. You can get your copy for FREE at http://www.peggit.co.uk

Android presented me with a considerable number of challenges over the other platforms. Primarily this was due to the various devices which run Android and their varying screen resolutions, processing power, and capabilities. You may notice from the app screenshots that the finish flag is not in the same position as on the other platforms. This is because the finish flag location on the Android version is dynamically placed, calculated from a formula based on the landscape screen resolution of the device upon which it is running. Each touch of a button moves Mr Peggit a set number of pixels, and to ensure fairness between platforms, Mr Peggit must move only a set number of places. Because pixels on the screen are whole numbers, and you can’t move Mr Peggit 1.5 pixels, the finish flag has to be moved to a position at which the total distance to run (in pixels) is divisible exactly by the number of pixels Mr Peggit moves on each frame of animation. Still with me? Basically… at some point I need to come up with some sort of fix for this, but my brain was hurting with the logic so I just moved the flag instead.

The next stumbling block was how to uniquely identify each user on my Peggit score server. Microsoft provide an anonymous ID, Apple allow you to retrieve the device’s unique ID which I can encode and use, but Android doesn’t have a single consistent way of identifying a user or device. So… by taking a combination of things a device may or may not have, such as the mac address of the wi-fi adapter, sim card IMEI, device serial number, etc, adding them together and hashing them, you can get an ID which identifies that device. Long winded, but some devices don’t have wi-fi, other Android devices don’t have sim cards because they aren’t phones. All very complicated stuff which Google really needs to sort out.

Anyway, issues aside, the game works so enjoy!


Wacom Bamboo Tablet

February 25th, 2012 2 Comments »

With all the talk about tablets and iPads lately, you may be forgiven for slightly misunderstanding this product. This is a tablet, but not a tablet of the same ilk as the iPad. It’s a USB connected mouse replacement peripheral commonly used by graphic artists to provide a more natural pen-based input to a computer. You may notice that the Amazon linked product doesn’t look the same as the one in the photo below. That’s because although you can still get this model, the new model is supposedly better and cheaper, so I felt it more appropriate to point you in the direction of that one instead. This isn’t my gadget, and it’s a few years old now so has been superseded by newer models which offer significant improvement, but nevertheless I’m loving it. I’ve borrowed it in order to create the artwork for Peggit. My wife is more comfortable with using old fashioned pen and paper to sketch out drawings, but these are very difficult to use directly as graphics in a game.

So, I devised a plan: My wife carried on and sketched out her drawings as usual, I then scanned them in and imported them as bitmaps in to Adobe Illustrator. Using the Bamboo tablet and Illustrator’s calligraphy tool I traced over the scanned image on screen to create a vector-based outline. Illustrator nicely smooths out most of the irregularities and produces a reasonably clean and professional sketch, and coupling it with the tablet for finer control gives you a really easy way to transfer drawings like this. Now… the next step will be to convince The Wife to draw directly in to Illustrator in the first place. Sadly I messed this bit up as I initially sat her in front of Photoshop with the tablet. Photoshop doesn’t offer the same friendly calligraphy tool and consequently incorporates all of your bumps and wobbles which slightly knocked her confidence in her own abilities. I’m working on it though…!

Peggit: Behind the Scenes

February 18th, 2012 1 Comment »

The observant amongst you may have noticed a new logo appear on this blog, labelled Peggit. Peggit is my first attempt at a smartphone game and at the time of writing is available on both the iPhone and Windows Phone 7 platforms. I’ll not discuss the game itself here – you can check out http://www.peggit.co.uk for that, but instead talk about the technologies behind Peggit and just to make a point that even the simplest of games require an incredible amount of complexity behind the scenes.

My intention with Peggit was to create a cross-platform experience allowing players to compete with friends no matter what type of smartphone they use. Firstly, and most obviously, both iPhone and Windows Phone development use different languages, SDKs, and development environment, namely Objective-C and Xcode for the iPhone, and C# and Visual Studio for Windows Phones. This poses a cross-platform problem – how do you share scores? iPhones use the “Apple Game Center” to store and share game-based achievements, while Windows Phones use Xbox Live.

These obviously don’t and won’t talk to each other so I’m left with one option – create and host my own score server. After a bit of investigation I settled on a protocol known as REST (Representational State Transfer). Using a reasonably standard web server configuration of LAMP (proudly hosted by Vidahost!), I set about implementing a PHP based REST API. REST works by accepting input via a regular HTTP request, or a URL if you like. The URL is interpreted by the REST server and translated in to a PHP method call along with any applicable parameters. For example /getScores/1/50 could be interpreted as “execute the PHP method getScores(gameId=1,numberOfScores=50)” in pseudocode. For a bit more elegance, parameters can be embedded in an HTTP POST request.

Now, this is obviously a very easy way to send data to the server, but you need to be able to get a response from the API, or functions such as getScores are useless! There are two primary methods for returning data using REST: XML and JSON. XML probably doesn’t need explaining – a schema is agreed between server and requestor beforehand and the returned data is encapsulated accordingly. I chose JSON instead though for one main reason: Peggit is a smartphone game which means it will most likely be used by people who are out and about. Data costs on mobiles can be expensive and the speed of those data connections can be slow. JSON, unlike XML, is very lightweight using a fraction of the character overhead that an equivalent XML response would contain. JSON allows me to push the minimum possible data to the app in the minimum amount of time meaning that not only is the transfer more likely to happen, it is also less likely to upset those with mobile data caps. Windows Phone supports Web Services and JSON out of the box using a simple asynchronous WebClient call combined with the System.Runtime.Serialization.Json library. Xcode for the iPhone sadly needed a little more assistance and I had to use the 3rd-party ASHTTPRequest libraries for asynchronous web service calls, and the 3rd-party SBJson library to interpret the results. Apple’s products may “just work” for end users, but they don’t make things easy for developers.

Up on the server, the REST API is paired with a MySQL database, hosting all scores. PHP takes care of the intelligence, ensuring integrity of the data and making sure that only the 10 best scores per player per game are kept. Players are uniquely identified by an anonymously generated string, passed to the API from the phone. This way, no personal data is ever stored (unless you count the display name), and just to ensure that privacy is adhered to, all traffic transferred between the server and the smartphone is encrypted using SSL.

Back on the phone, a simple web service call is made to the REST API on the web server as required – responses are processed using a JSON parser and stored as objects in memory for only as long as needed (usually just to display on the screen). The one exception to this is the storing of the user’s top ten scores per game. As I discovered whilst creating my last app, Watercolour Reference, the easiest way to create a local database on each smartphone is to use SQLite.

Although not explicitly supported on Windows Phones as they use a portable Microsoft-based database as standard, a third party library (Csharp-SQLite) can be utilised meaning that a single SQLite database can be used on iPhones, Windows Phones, and Androids, and the same SQL queries can be copied and pasted between apps saving hours of development time. The top 10 scores are stored in such a local database, and when the app is executed for the first time it will look online to see if scores for this user are available. If they are, it downloads them and populates the local database. Each time a new score is added to the local database, the app will also upload it to the server.

And that’s all there is to it from a technology perspective! A total of 7 different languages were used to create the finished product (C#, Obj-C, Java, Javascript, PHP, SQL, HTML), and yes, I’m counting the creation of the upcoming Android version and the development of the web site in there too.

BenQ G2220HD – Why have just one?

February 11th, 2012 No Comments »

It has bugged me for a while. Two monitors sitting on my desk, but not only are they different aspect ratios and resolutions, they are also different colours. They just didn’t match! No symmetry at all, grrrr. So, after a year of asymmetry I relented and purchased a matching BenQ G2220HD monitor. You may remember the review from the beginning of 2011, well, a year on and I’m very happy with it. So happy that I now have two of them. They new one is obviously a little brighter than the old one which has had a year to dim slightly, but it’s not that noticeable unless you look for it. I’m sure after 6 months of use they’ll both be pretty much the same. This monitor, at 21.5 inches and capable of displaying full HD 1920×1080 resolutions over VGA or DVI has got to be one of the best value monitors around still. Of course if you spend three times as much on another make of monitor you’ll get a better picture quality with less washed out colours, a better viewing angle, LED back-lighting instead of the fluorescent tube back-light of the BenQ. But then again, I’ve purchased two adequate monitors for less than the price of your one…. so it’s up to you to work out your needs! I highly recommend the G2220HD for the majority of users as it strikes the ideal performance/cost balance.

Kodak Pulse Wi-Fi Photo Frame

February 4th, 2012 2 Comments »

My parents live quite a distance away, my sister and her family live a little closer to them but still a good hour away too. In light of this and to ensure that the photos on it are regularly updated, instead of just buying them a normal digital photo frame for Christmas, we decided that an Internet connected device would be better – that way we could send new photos straight to the frame as soon as we had taken them. A quick scout around the web turned up the Kodak Pulse range of devices.
Available in a 7″ or 10″ screen size, of course you go for the largest!
The Kodak Pulse connects to your wireless network easily – setting it up is straight-forward using the built in touch-screen menus, and once connected it talks you through registering the device online. Each device has a unique code printed on the box, although when I set up the frame it gave me an on-screen unique code completely different to the one printed on the box… so the box code was never used. This unique code links your frame to the Kodak servers and your Kodak account.
Within your Kodak account you can assign a special @kodakpulse.com email address – this then becomes the primary way for remote users to send photos to the frame. When a photo is emailed as an attachment to your kodakpulse.com email address, within 15 minutes a little mail icon appears in the top-right corner of the frame’s screen. Touch the icon and you can review the new photos, and approve or discard them according to your wants.

Of course, the frame supports many other ways of transferring photos including the traditional “bung in a memory card of photos” method, but being Wi-Fi enabled you can also log in to the Kodak Pulse web site to manage the frame’s contents, upload photos from your PC’s collection, group them, enable/disable groups of photos, adjust the frame’s transition settings or power management, or any other setting which you feel needs a tweak. The interface is pretty well thought out and requires very little actual device interaction – the frame will just sit there happily accepting remote commands and images.

One of the neatest features of the photo frame is the Facebook integration. You can link the frame to a Facebook account, and then choose which albums on Facebook you would like to be displayed on the frame. You can choose to display specific albums, all albums, or just recent images from your feed. In my case, I chose to link the Kodak frame to my mum’s Facebook account and display two specific albums – one managed by me, the other managed by my sister with both albums set to limit permissions down to just the three of us. The frame happily cycles around the images, displaying new ones as we amend the albums online. My one criticism of this integration is due to the low quality of the images – they appear highly compressed compared to images which are directly uploaded or emailed. This is a shame as it is one of the most convenient ways to manage photos on the frame.

For the power conscious among you, you’ll be pleased to hear that the frame has a built in motion sensor to power the screen on or off depending on whether is senses people are around. I can’t honestly say whether or not this is working because it’s always on when I’m around…
it might be turning off when there’s no-one there but who knows. We might have to set up a camera to watch it when we’re not around just to prove a point!

To summarise, this is an excellent photo frame and I am really tempted to buy one for my use too – the Wi-Fi connectivity and remote management has been implemented excellently so even the most amateur of consumers should be able to set this up.