Build An HTML5 Game – Answers To Exercises

My Build An HTML5 Game book is finally on the way, and the website to go with it is live too.

As well as info about the book it serves three main purposes:

  1. A place to see and play the Bubble Shooter game developed in the book
  2. Assets such as images and sounds to make the game
  3. Solutions to the exercises at the end of each chapter in the book

The last are only suggested solutions and there’s a comment form below and I’m hoping others will be able to improve on my coding here.

Posted in JavaScript, Programming | Leave a comment

Build an HTML5 Game – 40% Early Access Discount

Build an HTML5 GameMy book Build an HTML5 Game in going to be out in a couple of months, and until around 4pm on January 31st 2015 you can get 40% off with the discount code BRIGHTANDEARLY if you buy it here:

The discount applies to ebooks or the physical copy too, although it’s only if you’re in the United States that I guess the physical version makes sense, until it’s more widely distributed sometime in March.

Build an HTML5 Game

Make your own game without learning any new languages! With just HTML, CSS, and JavaScript in your toolbox, you can create a truly cross-platform game, playable on both desktop and mobile browsers.

In Build an HTML5 Game, author Karl Bunyan shows you how to create browser-based games by walking you through an in-depth tutorial on building a classic favorite, the bubble shooter. Along the way, you’ll learn how to:

  • Send sprites zooming around the screen with JavaScript animations
  • Cause exploding effects with a jQuery plugin
  • Use hitboxes and a bit of geometry to detect collisions
  • Implement game logic to display levels and respond to player input
  • Convey changes in game state through animation and sound
  • Add flair to a game interface with CSS transitions and transformations
  • Gain pixel-level control over the game display with the canvas

Hit the ground running as you start programming the bubble shooter from the very first chapter. Exercises at the end of each chapter test your new skills by challenging you to dig into the bubble shooter’s code and modify the game.

You can create a complete game right now, with skills that you already have. Let Build an HTML5 Game teach you the basics, and then transfer that knowledge to create any game you can imagine.

Get 40% off with the discount code BRIGHTANDEARLY if here:

Posted in JavaScript, Programming | Leave a comment

Cafe Finder Website And App For Cyclists

Halfway Coffee - Cafes for CyclistsI’ve been out riding with the Lea Valley Cycling Club a few times now and the route planner, John, has a good stock of cafes in his head that we can use as drop-off points. The problem is, I’m not always going to be out with the club, and I’m not always out in a part of the country I know.

Now, I might be able to find just any cafe, but it seems that cafes that are welcoming to cyclists have a few special qualities: plenty of space to stash bikes, even if you won’t have a lock with you, generally out of town, and a good selection of high carb food and tea.

There seem to be a few websites that try to list cafes. Cake My Ride is pretty good and BikeHub claims to be, but I couldn’t really find much apart from route finding.

Anyway, of course I decided to build a website myself, and an app to go with it. It’s called Halfway Coffee and you can search for cafes by location or add a new one. The iOS app or Android app show you cafes that are nearby or let you add or rate one that you’re sitting at.

Will anyone apart from me use the app? Possibly, but probably not many. But at least I’ve got no excuse for not being able to find a good cafe stop in the future.

Posted in Cycling | Leave a comment

My Prudential Ride100 Experience

Ever since I had the confirmation that I’d gotten a place in the Ride 100 ballot I’d been viewing August 10th with a mixture of excitement and trepidation. Excitement, because it was going to be a great challenge, and trepidation due to the distance. I’d been building myself up since the beginning of the year, but given how exhausting even the lift from a 50 mile ride to a 60 mile one was, I wasn’t too sure about the idea of making 100 miles with anything less than complete exhaustion and, not to put too fine a point on it, severe bum-pain (not a technical term).

In the last months before the event, though, I’d put in a few much longer rides, including 94 miles about 10 days before the event. This put me in a much more positive frame of mind and “I think I might be able to do this” was being replaced by “I might actually enjoy doing this”. Trepidation started to recede and excitement came to the fore.

Then, with a week to go, trepidation was given a major boost: the remnants of Hurricane Bertha were going to be heading across the Atlantic and they might – only might – be hitting the UK on Sunday August 10th. Of course, this meant they were certain too, and indeed they did. Obsessive checking of every weather site in the days leading up to the event and trying to believe whichever forecast was the most forecast didn’t really help as they all trended downwards as the day approached. On the Saturday afternoon, the rain forecast from the Met Office was the picture below:

There were weather warnings in place regarding rain, flooding and wind. Perfect cycling conditions.

On the day, things didn’t look too bad. Rain had fallen overnight but, even lining up at the start, there were grey skies but not too much wind and only a hint of rain here and there.

One thing for sure: there were a lot of cyclists. The organisation involved in getting some 24,000 away was impressive, and I set off a bare 10 minutes after my allotted start time, although a couple of hours after the first fast riders had left.

As many had said it would, the ride started much faster than a casual ride in the country. I was overtaken by pretty much everyone as I stuck to somewhere between 15mph and 20mph, making as much as I could of sitting behind anyone going about the right speed and big enough to make a hole in the air for me to follow. The roads were wet so if they had mudguards it was even better.

Rain came and went, but the weather didn’t seem too bad. By the time we were in Richmond Park there’d been a few light showers but nothing to complain about. There was also a hundred yards of walking due to an accident that didn’t look very nice at all.

Once on the southwest side of London, however, the heavens really opened. The waterproof jacket held up for a while but nothing could keep that amount of water out, and soon my pedal strokes were accompanied by the feeling of water sloshing in the bottom of shoes. We kept going, of course, trying to avoid the rivers that were running across the road.

By about mile 35 the energy levels had dropped, though, and for about the next hour I didn’t hear a single rider speak a word. It was like we were all cycling our way across the river Styx and no-one was in the mood to talk. Also, I was dying for a wee by that point, and also hadn’t eaten as much over the past half an hour because I didn’t want whatever I consumed to be ninety percent rainwater. The top point at 40 miles were advertised by the marhalls (that must have been suffering at least as much as the riders) as “water and toilets; long queue for toilets” so I kept going. The next five miles of country lanes were strewn with men peeing in hedgerows.

Somehow, I managed to cycled up Newland’s Cornder, supposedly one of the three big-ish hills, without knowing that that’s what it was, and I was suddenly at the halfway point. I needed water refill, bladder emptying, and stomach filling, so I went into the “hub”, as they were called. Thankfully there were no queues, and after the water refill I ate my way through a ham sandwich whilst sheltering under a large tree that was keeping the worst of the horizontal rain off.

Fifteen minutes later I gave my gloves a good wring out and set off again. The rain had eased by now and was just rain rather than a waterfall, but the roads were often flooded to the point where the riders had to slow to a narrow filter to weave around lakes. The organisers had taken the decision to shorten the route to avoid the two steep hills – not because of the climbs, but because of the descents – which I don’t think anyone could disagree with, although it was disappointing that now the Ride 100 would only be the Ride 86 as there were 14 miles lopped off.

As a result, after some rolling hills and drying conditions, I found myself at mile 81 (which was really mile 67) rather quickly, and stopped for a last water refill. I ditched the rain jacket as well and took out the spare gloves that I’d wisely packed in the inside pocket for when conditions dried out. These were, of course, almost as soaked as the gloves I’d been wearing, but they were lighter material so they couldn’t hold so much water.

With only 19 miles to the finish, and having had the distance shortened, the last hour and a bit was a very pleasant fast ride into town. Again, I skipped from back wheel to back wheel, and by this point I was only being overtaken by 50% of the riders on the road rather than 100%, which made me feel better about a more moderate easy pace. The wind was strengthening too, but it was coming from behind so it was easy to keep close to a 20mph average, even with all the wet corners we had to slow down for. I don’t think I’ll ever forget the flooded tunnel beneath some railway tracks that many of the cyclists walked around. I cycled through, but at every pedal stroke my feet dipped into the water which was a good four or five inches deep.

The Mall appeared in next to no time and then it was time to dismount, collect a medal and then suffle through to the goody bag collection and out. At least I had the ride home to top the miles up, and I think I totalled 98 miles by the end of the day. I’ll just have to do the 100 miles some other time then.

Ride London Medal

Despite the atrocious conditions, I’d completely do the whole thing again, and now need to find another cycling target to aim for. Maybe something a bit shorter, but a bit faster… maybe.

Anyway, things that I learnt:

  • As many have said, riding in a big group is a lot faster than riding on your own. Solo training is much harder than the event, and the speed you can cruise at in a group makes travelling such a long distance very satisfying.
  • If you see someone doing something like this on a Brompton, it’s likely they’re extremely fit. I know I overtook some people who passed me early, but Brompton guy was off into the distance never to be seen again.
  • Starting off slow definitely pays off towards the end.
  • If you ever get the chance to cycle on closed roads, just do it

Now I just have to see if I can get in for 2015 somehow.

Posted in Cycling | Leave a comment

Le Tour de France? Non, c’est le Tour de Leyton

The Tour de France came through Leyton earlier today. I had a very productive afternoon watching it on the telly before deciding I’d better go and grab a spot to watch it go past in the flesh. Orient Way was empty enough to get some photos and provide a nice long view of the peloton, although at the speed they go through it was all over in a few seconds anyway. Still, I can say: I was there! And I have photos to prove it.

Before the cyclists came through there were dribs and drabs of cars. This one at least has the logo on the front, but note the French determination to persist with speaking their own language also carries over to driving on the wrong side of the road even when we know they could keep to the left if they really wanted to.

You can’t get much more French than a Carrefour car on the wrong side of the road:

Although a quirky little van with the Tour de France logo on the front comes a close second.:

I’ve always thought of French as having too many language constructs getting in the way of saying what you really mean. This gets around it by only having the important words on the bonnet and no niceties of language at all. There can be no doubt what “FranceTVSport” does”:

This is the last of the car shots honest… It’s the neutral service vehical, driving well in front of all the cyclists because… well, I don’t know why. In case one of them teleports down the road and then breaks down, I guess:

Not only are they sending cars with their supermarket logos on over here, there were a few gendarmes that snuck in with the rest of the vehicles:

As the TV helicopter came into sight I knew the peloton must be getting near and things started to get exciting:

The breakaway of Jean-Marc Bideau and Jan Barta comes around the corner. I hadn’t seen the race pictures for half an hour and my phone had given up on having a data connection so I was surprised they were still in front:

Another shot of the two valiant breakaway riders. They were soon doomed to be swept up by the chasing bunch, but they lasted longer than I would have expected just two riders to have managed:

Shortly afterwards the main peloton came tearing around the corner surrounded by motorbikes:

The main peloton came tearing past with the whirring of mechanical parts and only a few organising shouts, and within a few seconds they were down the road and out of sight again. It’s a shame it was too early to see the sprint lead-out trains forming but there was a tricky turn up ahead so they were still in a racing frame of mind:

And with that the Tour de France had been and gone, and I rode home and went back to the telly to see the conclusion on the Mall.

Update 8th July

I was on the telly! If only just. Standing on an isolated stretch on the wrong side of the road had the advantage of making me easy to spot. I’m the one in the yellow t-shirt on the right:

Posted in Cycling, Leyton | Leave a comment

Cycling A Long Way

I’m due to cycle 75 miles on June 22nd as part of the Capital to Coast ride for Norwood. Although, as the event starts at the London Eye, I also need to cycle there, so I’ll have covered close to 85 miles by the time I reach Brighton in the evening. That’s a good 20 miles farther than any ride I’ve done in the past.

To follow it up, I have the 100 miles of the Prudential RideLondon-Surrey 100 on August 10th. Although that starts only a couple of miles away, I’ll have to make it back home in the evening so it’s likely I’ll end up with 110 miles by the end of the day. This is officially quite a long way.

I’m obviously raising money, since it seems the done thing, so this is the pimp my JustGiving page section. The whole thing is actually going to be quite a stretch for me, I think, and if the few longer rides I’ve been on are anything to go by there are a couple of long days in the saddle that will not be fun by the end.

I’ve never previously taken cycling seriously. I’ve commuted and generally zoomed around London, but with the prospect of some proper rides on the horizon I thought I really should find out how to make it through them. My revelations so far are:

  • The poncy clipped shoes and pedals really work. Now I can’t imagine going back to my all-purpose shoes
  • Likewise, shorts and jerseys and wicking t-shirts are really good. I save the shorts for when I’m in cyclist-only company, but the jersey is worth wearing for anything more than a few miles
  • It’s really important to eat and drink whilst cycling. Maltloaf has been my food of choice and I can fit a few slices in each jersey pocket.
  • Don’t try to eat or drink whilst cycling up a hill.
  • For fitness, rides should either be intense efforts or long and slow. The inbetween state of getting generally tired at a middling speed doesn’t really do much beyond a certain point.
  • From riding with Lea Valley Cycle Club, and being passed by many other road cyclists, it’s obvious that there are some really fit people out there. I will not be keeping up with them on either ride.
  • However, I am better prepared now than I was last time I did a 60-mile London to Brighton ride
  • Cycling a long way is really tiring. This is probably not news.

My standard route has been growing and started with a slow ride up the Lea Valley towpath and then a loop back along the road. I’ve been lengthening it by adding loops so that the last two rides took in Waltham Abbey, Epping, North Weald Basset, and then out to Matching Green. It’s about 50 miles in all, which was plenty, especially the first time I attempted it.

Longer rides are going to be needed, especially before August, and I’ve now got about four weeks where I reckon I need to fit in at least a couple of 70 mile rides. So if you fancy encouraging me, here’s the JustGiving page again.

Posted in Cycling | Leave a comment

Appearance on the Backendy podcast

I’ve made an appearance on the Backendy podcast in which I chat with friend and former business partner Darren Beale about flying a plane, Facebook game development and advertising of the past, and various business and business-of-tech type things.

You can download the episode here or on iTunes, where you can also subscribe for future episodes.

Posted in Other, Programming | Leave a comment