Pirate Empires: Part 1 - Lagging Behind Next

Pirate Empires developer diary banner

Before we start talking about Pirate Empires, it's worth mentioning that this will NOT be the next game we release - in fact, this game may not be released for many months. We will, of course, be releasing other games and updates before this game comes out. For the last few months, Mod Wivlaro has been working on FunOrb's pirate-themed game with Mod Dunk, and he has a few thoughts to share with you below. You may remember that we had a competition on the FunOrb forums to suggest names for this game; unfortunately, the winning suggestion – Pirate Lords – turned out to be already in use, so we’ve had to go with the slightly different name of Pirate Empires.

11th March 2009 – Lagging Behind

Concept art
Concept art for two of the proposed factions.
Click here to see a larger version of this image.

Most recently, I have been trying to get the network (i.e. multiplayer) code to handle lag better. The FunOrb team is developing a number of real-time multiplayer games at the moment, and doing this in a browser is always an interesting challenge, particularly considering the distances and latencies involved. We have to fight some dreaded lag-monsters! Getting the code to handle ships sailing around in the wind wasn't too tricky, but when you order your crew to "FIRE!", you expect them to do what they're told immediately.

The solution we’ve come up with is to attach a time stamp to every order given by everyone who’s playing. When an order has been sent to our server (which might be subject to lag), the server rewinds the game, inserts the order at the right time, then plays the game forwards again, before sending the new updates to players. While this is happening, the client (the version of the game running in your browser) has to play out any orders you have sent, but which have not yet been confirmed by the server. Phew!

Prototype game engine
A screenshot of the prototype game engine.
Click here to see a larger version of this image.

When one player fires their cannons, the server prioritises sending this information to the other players so they're not left behind with what's going on with those crucial cannon-balls! Then, before you can say "Davy Jones's locker", we have to play the cannon-balls’ sound effects; draw them on the screen at (the client’s best guess of) where they should be; animate them flying through the air in a realistic way; and, finally, figure out if they crash catastrophically into other ships or splash disappointingly into the sea. There are so many things to deal with, and they all have to happen in a very short space of time in order for it to look as cool and believable as we want it to! It might sound complicated, but if we do a good job of it, you won't notice a thing while you're actually playing - you'll just be focusing on blasting enemy pirate ships out of the water!

Mod Wivlaro
FunOrb Developer
(Pirate beard length: 3mm)

Back to the top