Idle thoughts and technical knots.

Critter Quest: Papertanks adventure into game design

As a digital design studio, through no specific course of action, we seem to have become a specialist in sport and activity tracking apps.

Beginning back in 2010 with a simple marathon directory, word spread and we started getting more and more enquiries, soon branching into full scale projects such as World Walking, Ramblers and Big Team Challenge.

This is what led Glasgow’s Queen Elizabeth University Hospital to our door and took us down the long and eye opening route of game design and development.

From the initial meetings we held with the hospital staff and funders at Glasgow Children’s Hospital Charity, it was clear that they were after some method of both motivating children to aid their recovery and for the staff to be able to track the patient’s progress as they did this. A clear inspiration for the project was World Walking’s website and app, that uses your real life activity to move you along a virtual route. It’s a tried and tested method that has been very popular amongst it’s 20,000+ users, however there’s a catch, most of World Walking’s users are adults.

When it comes to specifically capturing the attention and imagination of children, you have to approach every aspect of a project from a different perspective. For this concept to work we would have to abandon our pre-conceived notions of what an activity tracker should be and explore new avenues of creative thought. During the research phase it became clear that not only was developing a game our best chance at creating an engaging tool for the hospital, but was a fantastic opportunity for our studio to hone a completely new set of skills.

Delving right in, the first challenge for developers Michael Park and Fergus Howe was to find the best software for creating the game itself. The decision came down to the two main applications: Unity and Game Maker Studio 2. After testing on both platforms, Game Maker Studio came out ahead in the end and so began several weeks of testing the limits of the system and exploring how we could utilise this new tool.

As with every project there are inevitably compromises that have to be made between what you dream the project can achieve, and what the time scale will realistically allow. For us an incredibly tight deadline of 6 months was the monster we had to bear and so we had to set in motion a very clear timeline of research, design, development and testing. Ideas had to be refined, refined and refined again so that when it came time to implement, nothing was wasted. What came out of this was an idea to create a game set in a “fantasy” setting, with the main character set out onto a world map to travel, discover and record the towns and “critters” they came across.

Choosing to use “collection” as the main game mechanic not only allowed us room to expand the game if we had the time, but also gave us the opportunity to be creative with the elements, their design and even the story behind them. One major example of this was our choice to add in a “trading card” element, which the player can collect throughout the map.

Our next big problem solving session came in the form of tracking the children’s real-life physical activity. After several approaches including the possible use of GPS trackers or pedometers, we settled on a much more inclusive form that wouldn’t rule out users without these devices. Our solution was a much simpler idea: we would simply ask the users what activity they had done.

Each activity they choose has a corresponding ‘Gold Coin’ value and the more time they spend on that activity during the day, gives them a higher reward. To help reduce incorrect inputs, we added an extra step that requires a parent or guardian’s pin number input. It’s not a perfect system, but it’s one that we feel is the best possible solution to a very specific requirement for a project.

Currently the app is being piloted in the hospital with a closed off registration, so unfortunately the app is not open to the wider public. But if the test phase is successful there are plans to develop the game even further and open it up.

Working on this project has allowed Papertank to stretch some development, illustration, animation and storytelling muscles we don’t often get a chance to show off. We hope that the internal testing phase is a huge success for the hospital and look forward to working on it further in the future.

Setup Laravel queue on shared hosting

We specialise in bespoke web and mobile development at Papertank, and we’re proud to use Laravel as our PHP framework of choice on web and API projects.

When it comes to hosting a Laravel application, installing on a shared host is perfectly possible, although we normally use a more powerful VPS server for more flexibility and control. We’ve previously blogged about setting up installing Laravel on shared hosting on papertank.co.uk. If you do go down the shared hosting route, you’ll want to make sure you are using a decent web hosting company. This will save a lot of headache and make deploying custom apps much easier. We recommend Cloud Above in Cornwall for great value and support.

Modern web apps use queues for background job handling of intensive tasks, allow your API or front-end app to return data, redirect the user, or perform other actions without waiting for the ‘job’ to finish. Laravel’s driver based queue system makes this easy to set up with Beanstalkd, Amazon SQS or Redis. Unfortunately shared hosting makes using these services difficult or impossible, since your host will often forbid installing software or logging in as root.

Laravel 5’s new database driver fills in for other tools, storing the jobs on a database table – https://laravel.com/docs/5.2/queues. The next step is running or listening for jobs using the command line ‘artisan’ tool, which can be a little tricky on shared hosting without process monitors. To get around this, you can use a cron job which can usually be setup in cPanel on shared hosting, however cron jobs can only be run once per minute which isn’t ideal for high traffic websites.

As a workaround, we recently customised a Laravel web app using the built in Task Scheduler. By setting up the server’s cron to run the schedule:run command every minute, our application spawns off a new queue:listen process and checks to see if it needs restarted every 5 minutes.

/**
* Define the application's command schedule.
*
* @param IlluminateConsoleSchedulingSchedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
	$path = base_path();
	$schedule->call(function() use($path) {
		if (file_exists($path . '/queue.pid')) {
			$pid = file_get_contents($path . '/queue.pid');
			$result = exec("ps -p $pid --no-heading | awk '{print $1}'");
			$run = $result == '' ? true : false;
		} else {
			$run = true;
		}
		if($run) {
			$command = '/usr/bin/php -c ' . $path .'/php.ini ' . $path . '/artisan queue:listen --tries=3 > /dev/null & echo $!';
			$number = exec($command);
			file_put_contents($path . '/queue.pid', $number);
		}
	})->name('monitor_queue_listener')->everyFiveMinutes();
}

The full code for this setup is on Gist at https://gist.github.com/davidrushton/b7229df4c73372402fc1

If you’re looking for more help with Laravel, you should check out the following websites which we subscribe to and read regularly.

Of course, if you’re looking for a Glasgow based company with experience building advanced web apps with Laravel then please get in touch

Glasgow Life iPad Apps

This year has been a big one for us in terms of App Development. Not only have we been producing a variety of our own projects (Trivia Night and Sharpen) but we’ve had the amazing opportunity to work with some really exciting institutions.

Glasgow Life
We were fortunate enough to get to work with a selection of Glasgow’s finest museums this year, producing both in-house exhibition apps and appstore releases.

Century of Style
This beautiful exhibition of 19th-century clothing comes from Glasgow Museums’ collection of European costume. The app allows you to delve into details of each item and discover its history in greater detail, as well as zoom in on some of the finer details using high definition photography.

Century of Style – App Store Release

Scotland Street
Scotland street has always been a hub of information for the history of local schools and those that attended, but a lot of the information has been difficult to obtain.
A new push has been made to digitise a lot of the old records and photos, with a custom app being displayed on iPads throughout the museum to help suers interact with it.

Visit Scotland Street Museum for a hands on experience with the app.

Archaeology Companion
Kelvingrove Museum has always been home to a hugely impressive collection of archaeological treasures, ranging from stone age to medieval periods.

In order to bring their new exhibition to life, the museum commissioned us to produce an iPad app that would allow visitors to learn and discover interesting details about the individual items on display. Along with the detailed records, the app also allows users to zoom in on high definition imagery and even pinch, zoom and ‘spin’ detailed videos of certain objects for a closer look.

Visit the museum’s Study Centre upstairs to interact with the app in person or download free from the AppStore.

An Archaeology Companion – App Store Release

Trivia Night App for tvOS

Trivia Night App is our latest adventure into the world of Apple Operating Systems. This time with the (as yet) uncharted Apple TV.

With the new hardware’s upcoming launch announced to the world, our long time collaborator Michael from Turing came to us with the idea of creating a tvOS trivia app, that players could interact with using an iOS version on their phone or tablet, essentially creating their own personal controller.

The game allows up to 6 players to join into a points based trivia game hosted using the Apple TV. All that is required is for the users to download the free companion app onto their phone or tablet, make sure wifi or bluetooth is turned on and follow the simple instructions.

 

Zero Downtime PHP Deployments

Modern PHP Deployments

We do a lot of bespoke web application development at Papertank, and we specialise in PHP for our server-side web and API projects.

PHP has come along way, and the whole platform has matured significantly in the last 5 years. In addition to core improvements and standards initiatives, the introduction of the Composer Dependency Manager (getcomposer.org) has been instrumental in allowing developers to share and ‘require’ other open-source projects within their applications.

We use Composer on our bespoke web projects, allowing us to install, update and manage all of the packages and libraries our websites and APIs use.

The Dreaded Downtime

Inevitably all software needs updated, and updating can be a pain. We use Git version control repositories and Composer, but sometimes things go wrong, and even when they don’t they can take a website offline for several minutes while the code and database is updated.

Our Zero Downtime Solution

A few months ago, we picked up on a server technique to deploy projects with zero downtime – effectively by linking the web root directory to the most current ‘copy’ of the application / code.

Using Laravel’s Envoy Task Runner, we then developed an automated process of initialising, running and cleaning up your deployments via the command line on your local command line. Envoy runs a series of commands on your remote host and restarts your web server, effectively resulting in no downtime when deploying complex updates including database migrations and composer updates.

Our code lives on Github at https://github.com/papertank/envoy-deploy and is specifically designed for use on Laravel 5 projects. However, the idea can be expanded for any PHP or non-PHP projects, and the Envoy command line runner can be used independent of Laravel.

How it Works

Your server will look something like this after you init and then deploy with the script

20150317110501/
20150317114500/
current -> ./20150317114500
storage/
.env

 

As you can see, the current directory is symlinked to the latest deployment folder

Inside one of your deployment folders looks like the following (excluded some laravel folders for space)

app/
artisan
boostrap/
composer.json
.env -> ../.env
storage -> ../storage
vendor/

 

The deployment folder .env file and storage directory are symlinked to the parent folders in the main (parent) path.

Websites we now use this approach on have 100% uptime.

Find out More

Our GitHub project – https://github.com/papertank/envoy-deploy

Not comfortable with the command line? – https://envoyer.io is a great service that offers the same feature through a web interface

Servers For Hackers did a great video showing a similar setup in more detail – https://serversforhackers.com/video/enhancing-envoy-deployment

Are you a client interested in a no-downtime web application? Get in touch