Making an efficient gameserver with node.js and mysql (Musclecar Online)

Last year, when one of my games went a bit viral, I discovered first-hand about the alarming inefficiency of Apache (webserver), especially when running PHP which forces you to accept a process-per-request approach. It became pretty clear that something much more lightweight would be required if I wanted to build gameservers with large player-bases in mind.

After some research I have settled on node.js as a good solution. It’s very well regarded, largely due to its non-blocking, asynchronous model. This essentially means that anytime a resource is required (such as a database recordset) the request goes into a queue, to be called back when the resource is retrieved. In Apache, the model is blocking – the process sits and waits for the resource, thereby stopping any other activity.. this is why Apache needs all those independent processes, so that it can serve multiple clients simultaneously.

speedracer The game I have been working on is ‘Musclecar Online’ – a top-down racer in which players build their own tracks, vote on them, and then everyone in the world races on the same track-of-the-day. Rather than being real-time, you race against the ‘ghost lap’ recordings of other players; kinda like Speed Racer ;-)

Cache stuff in RAM

Linux has a server’s approach to the file system, of course, which means it uses all available RAM for caching disk files and such, but I figured it would be even better to make liberal use of Javascript arrays (which are really hash tables.. excellent for key-based lookups). So the server packs up canned responses into strings, as much as possible, ready for delivering over the interweb with no fuss or processing. This includes:

    a 5-day pack of track layouts, allowing the players to see what’s coming up over the next few days;
    per-cartype, per-second frequency bins, succinctly providing the data needed by the client to display a histogram of worldwide laptimes and point out where the player stands versus these;
    a temporary array of ghost lap recordings, hashed by user ID for easy over-writing when they improve. This is only used up until 40 players have recorded laps for that car type on that day’s track, and allows random ‘unclassified’ packs of ghost laps to be delivered to players without the need to bother MySql about it;
    more long-term packs of ghost lap recordings, separated into 6 divisions (F thru A) – the idea is that the player starts off racing against poor ghosts, labelled as division F, and if they beat these they are allowed to progress to division E, and so on. These longer-term packs are re-generated periodically, but not for the first time until 40 recordings are available for the car type.

Don’t fall into the ORDER BY RAND() trap

I have done some pretty naive stuff in MySql in the past, but running Darkwind for the past 7 years has helped me understand efficient database design and querying. With the characters, vehicles and weapons tables running into the millions, I was forced to. One of the newbie gotchas in MySql is to avoid doing a massive SELECT statement with ORDER BY RAND() LIMIT 1 in order to get a random record. If you do this, you’re basically asking the database server to load an entire table into memory, apply a random number to each record, sort the whole damn thing, and return one row. There’s a few obvious solutions, depending on how well distributed the data in your index fields is. One simple way is just to find your data range (e.g. laptimes min and max), generate a random number in this range, and then SELECT the first row greater than or equal to this laptime, LIMIT 1. Assuming laptimes is an index field, and also assuming there are enough records to make a reasonably even distribution across the data range, this works nicely.

Interesting asynchronous design solutions

Now, I love callbacks as much as the next man, but it can be an old-fashioned PITA sometimes trying to work with asynchronous coding. In a nutshell, anytime you want a resource that may be delayed (database query, file read etc.) you can’t use a traditional flow of control, can’t use loops for multiple accesses, etc. One of the things I have to do in the ‘Musclecar Online’ server is build packs of typical ghost lap recordings, in order to pack them into strings ready for dispatch to the clients. This means querying for each row with a separate SELECT statement, and therefore means 11 car types x 6 divisions x 5 different packs x 4 ghosts per pack = 1320 queries. Embedding each query inside the callback of the previous one certainly isn’t an option, but with a little thought I settled on recursion; a perfect way to unravel the asynchronous tangle. This works nice and efficiently, while still operating in serial (and therefore not choking up any server resources) and allowing nice tidy code. It’s kind of strange I didn’t see recursion mentioned as a solution anywhere on the web while researching node.js. Well, maybe I didn’t look for too long.


Let’s Break Stuff! – Best Casual Game award

Let’s Break Stuff! was shortlisted for 2 awards at the Engineers Ireland Game Developer Awards at the recent Games Fleadh 2013 in Thurles. I have been aware of this festival (now in its 10th year) but hadn’t travelled to it before. There’s a lot of impressive work going on there – kudos to Phil Bourke and his team at LIT-Tipperary.

Anyhow, LBS ended up winning the ‘best casual game’ award :-)


Asteroid Storm

Blast your way through waves of asteroids, beautifully rendered in 3D with powerups, shields, and plenty of explosions. Classic arcade action with modern graphics. Includes local and online high-score tables. Take too long on a wave and alien ships will hunt you down – just like the original game from the 1970s.

Available for Android on Google Play: Asteroid Storm Android -Free-
Available for iPhone/iPad on iOS store: Asteroid Storm iOS -Free-


Monster Melee

I have been doing some work on, among other things, a tamagotchi/pokemon type game called ‘Monster Melee’. You’ll basically build and train a team of monsters, going hunting against computer enemies and competing in online leagues against other players.

Here’s the starting character, Beetlejuice, in the ‘home menu’ environment – this is where you assemble your teams, feed and play with your monsters in a tamagotchi style, and launch your hunting missions.

..and here he is checking out the Graveyard arena. There will be arenas of various types, to match the monsters’ own specialisms – they will perform better in arenas where they have an affinity, and perform worse in ones where they’re uneasy. Luckily for Beetlejuice, there’s no enemies here yet ;-)


Let’s Break Stuff! socially

Well, the difficult road of putting together a social/multiplayer version of LBS is nearing its end at last. This was supposed to be a fun little addition to the game, but ended up being a lot more work than expected. I guess I’ll never learn ;-)

There’s a fairly hefty server back-end looking after the creation and management of the online games, stats and competitions, as well as the client-side work involved in searching for friends, chatting, viewing and launching games, etc. Also the integration of Facebook for logins challenges and brags, Push Notifications in order to alert players when they have moves pending, and some In App Purchases to (hopefully) make some profit from it. The core xml system for storing and recovering game states is retained from the user-created-levels system I wrote for LBS back in August, but that turned out to be just a small part of the task.

Now, I’m not sure if this will prove to be as popular as LBS singleplayer. But at least it’s nearly done. ;-)

Main website here
Android version here
iOS coming soon


Darkwind Developer Interview 2012

Back in June one of the Darkwind players, Groovelle, collated a bunch of questions from the players and we did an interview. I was kinda waiting for him to format/edit/sanitise/legalise it but he appears to have disappeared for a while, so I figured I’d edit it myself. So here it is…. the text is all verbatim apart from the headings, which are my own words added just now. And a few little jokes in squarebrackets

Hello, nice ta meet ya..

Jason : Hey Sam, this is Groovelle.
Sam : hiya :)
Sam : is JD joining us?
Jason : No, I think he said his internet was down
Sam : ah too bad, it could work well as a three-way thing
Jason : Indeed. I just wanted to start out by saying I really love most everything about Dark-Wind and it’s an honour that you’ve made time for one of your players
Sam : Thanks :) No problem at all, it’s always nice to talk about DW

Where did Darkwind come from? Ideas and Influences

Jason : We’ll start with a bit about Dark-Wind in general: What gave you the inspiration for Dark-Wind?
Sam : I guess it was a culmination of stuff. Firstly, my experience with MMOs such as Ultima Online showed me the potential as well as making me think there were things they were doing badly
Sam : Secondly, of course Cars Was. A game with excellent design but fatally flawed by the fact that humans have to run it: it takes too long to play. Computerising it all just makes sense.
Sam : This was something I had done before with an Amiga game ‘Critical Hit’; back in 1995 — which was a computerised version of Warhammer (tabletop wargame) except with the combat rules of MERP modelled on a per-soldier basis
Sam : I should say, there’s aspects of other games in there too. Football Manager, would you believe!

Jason : I had heard that about Football Manager and I can definitely see it. That was actually one of the things that intrigued me about seeing the stat/attribute sheet for the first time: There are tons of variables at work.
Sam : Tons of variables yeah. But more than that, it’s what I call ‘Playing Dolls Houses’. It’s a nurturing instinct, I think, that makes people love to control the life/career of digital minions. Men might not realise it, but I think they love it as much as women (except it tends to be about war)

Darkwind’s graphics, and lack of AAA-quality thereof, and what it tells us about the gaming public. In which Sam heralds the new Golden Age of indie games. Or something.

Jason : There seems to be an arms-race to photorealism in the last decade of gaming; you went a different way. What strengths and weaknesses did that present and how does that affect the tone of the game?
Sam : Well, I’d have to say I had little choice about going a different way; there’s no way I could compete with big games studios in terms of graphics. There’s clearly a weakness in that I have a hard time impressing new signups when they first check out the game. There’s a strength though in that I can add new game features with *relatively* little effort, since each feature doesn’t need to rely on slick graphics
Sam : BUT.. here’s something..
Sam : when DW was first released, 2006/2007, a lot of people used to log into the lobby and say how bad the graphics were, and leave
Sam : but NOW, less people do that
Sam : I think people’s expectations have changed in a way that has never before happened in computer games
Sam : and it’s probably mobile devices and casual games that we have to thank for it; the gaming public realise now more than they did that it’s not all about graphics; they really didn’t realise that in the early 2000′s
Sam : so now we have a new golden age of indie games

[pause... tumbleweed rolls by, etc...]

The Torque Game Engine

Jason : How hard is it moulding your vision into the confines of the aging Torque (TGE) engine, especially as you did it solo?
Sam : Well, given that I’m not relying on having cutting edge graphics, it’s just fine really. There are some design decisions that were forced on me (one being the ‘instanced’ combat system) but they have worked out fine and have actually fitted the way the game works nicely. TGE was a really well written engine.
Sam : Actually, one thing that was a f**king pain in the ass was the physics.
Sam : TGE has really botched collision detection and response, I had to put a lot of work into improving that (and it’s still pretty funky at times)
Sam : But it was a good decision to have an engine that gave me full source code, it let me do very unusual things such as having turn-based particle emitters for fire/smoke/dust

Perma-Death, PvP, the Economy and Travel

Jason : I noticed you mentioned Ultima Online. That had PvP (or PK) and in some areas was considered a gankfest. Dark-Wind has PvP and permadeath for players’ characters. Though players can have around 40 characters, making PvP work with permadeath seems like a daunting task. What lessons did you learn from seeing UO and how did you design around this? Do you envision anything changing about PVP? Would you have done things differently if you had the chance?
Sam : From a PvP point of view, I was really very naive. My ideas on that weren’t related to UO, they were just based on the concept that PvP should be open and the game should be brutal. As I say, very naive as in reality it’s much more complex than that and it will simply end up as a gank-fest if you let it! I have learned a lot, from running DW.. players are all different, and want to play in different ways, and each way is equally valid..
Sam : What I was actually referring to with UO specifically was travel. When I first read about the plans for UO, they had big ideas about having a dynamic economy where players would affect the world and the economic, ecology etc. This was all very exciting
Sam : But the reality was, they had teleporting, which destroyed any meaning in geographical distance, and therefore destroyed the concept of price differentials
Sam : they also neglected to take into account that everyone is an adventurer, which is .. eh.. a very skewed way to run an economy.
Sam : So I set out to have a behind-the-scenes simulated economy which is affected by players/adventurers bit which isn’t completed dictated by them
Sam : and travel… had to take time and be dangerous!

Jason : Travel really does give the Dark-Wind universe weight. I can vividly recall driving my first muscle car down south those 1500 miles + to Sarsfield and Firelight and being genuinely scared silly that my best character was in actual mortal peril. Looking back, especially in my time in UO, it seems this run should have been impossible. How does/did that balance work with travel, permadeath, and Dark-Wind?
Sam : I thought carefully about permadeath. I absolutely had to have it, because it’s just so stupid not to have it in a game, IMO
Sam : This is really part of the reason that I came up with the idea of a gang – so you could have permadeath but not lose everything

Sam : I’m not sure what you meant by travel fitting in with this?
Jason : Being ganked within the first few yards. I can recall, even after its heyday, trying to leave the first town (Britanicca was it?) in UO and being ganked. I’ve only been targetted once like this in Dark-Wind and the player who was trying to grief let me go when I conceded to him.
Sam : Yeah. Part of this is definitely about the maturity of the player-base. A turn based game would tend to draw a more mature audience.
Sam : Also, you were asking about whether I’d see anything changing with PvP or whether I should have done anything differently with it. In terms of future changes, I really don’t know. I have tried *many* times to tweak it and encourage it in different ways, but it never seems to have any positive effect: and it really all goes back to the fact that people want to play in different ways
Sam : If I had known that from the start, I guess I would have made the game explicitly about co-operation and PvE
Sam : I think we may have arrived at a good compromise position, where people can do pvp in deathraces etc. but don’t risk being overwhelmed in a more long-term way outside of their control
Sam : the game has for a long time been about evolution rather than design I guess

What’s coming next for the game?

Jason : Speaking of evolution: there are so many things bouncing around the Dark-Wind forums that might improve the game if added to Dark-Wind. Would you care to elaborate on the most pressing items you are working on in your “to-do” list?
Sam : There’s a lot of small things, many of which have been requested numerous times, that I’d like to implement. I don’t tend to get around to them too quick though. Some of the biggest undertakings that I have added in the last couple of years have, unfortunately, not turned out to be very popular. I’m talking about DW:Tactical and DW:Scavenger in particular, each of which were a lot of work.
Sam : Of the things that I have started and not yet finished, the ped-scouting “Into the Ruins” and the related “Ped Items” features would have to be the biggest. Both of these I really should have done a year or more ago, but they ended up being a lot of work when I started to identify the details of everything involved. The reality is, the game has evolved in many ways that I never envisaged back in 2005/2006 when it was all being designed, so this means some things are very awkward to retro-fit into the game. The idea of starting afresh, perhaps with a single-player version using a new game engine, is very attractive.
Jason : Exactly how big is your ‘to-do’ list?
Sam : LOL
Sam : 116 pages
Sam : But that’s not really all ‘to do’. It’s a document that I started in 2005 and just dumped stuff into, deleted stuff out as it was done. It’s a real alternative history of the game in a way. Lots of snippets from event logs where I found bugs, lots of bits & pieces as well as ‘to do’ items. But 116 pages in total ;)
Jason : Seems like you’ve got enough fodder for a single player version
Sam : more than enough yeah. The real task would be to stop it from being too wide in scope
Jason : So there’s “Into the Ruins” and possibly a single player version of the game you’re thinking about ; two is kind of a lonely number, got a top three priority list for the (nearish) future for Dark-Wind?
Sam : heh, you certainly got 2 of the 3 there
Sam : ‘into the ruins’ goes hand in hand with ‘ped items’ – that’s part of the reason it’s so delayed
Sam : better tutorial movies and tutorial events would probably be the other thing
Sam : I tried many different things since 2006 to try to improve the ‘new player experience’ – GUI overhauls, new website, etc., but the only thing that ever made a noticeable difference was the ‘new’ story-driven tutorial that we now have. Not really ‘new’ anymore.. ;)

What are you hiding?

Jason : You’ve been notoriously secretive about how all the attributes, skills, and hidden attributes and skills interact. Nobody really knows to-hit percentages or even what the numbers are behind gangers demoing (being stressed to the point of surrender) Why?
Sam : I think a game is much more realistic if you don’t know all the calculations and figures behind it. It also means that different opinions can co-exist and that there is no “right answer” or “best car design”. It’s a much richer experience.
Sam : It’s also the old-school approach I guess. In D&D we had the “Players Guide” and the “Dungeon Master’s Guide.” The latter had at the start, in bold text, “don’t read this if you want to be a player rather than a DM.” That’s the way it *should* be..

So is Sam the ultimate DW player?

Sam : Not that knowing the facts & figures helped me much BTW. Anyone who has played with me knows that I’m pretty crap at playing DW ;)
Jason : ( :) )
Sam : there’s actually a funny acecdote on this one..
Sam : about a year ago I was doing a scout with a bunch of people. I saw this hillock and put my flag on it, suggesting out loud that we assemble there.
Sam : No one answered.
Sam : After a couple of mins I looked around and saw a bunch of flags on a different hillock much further away from the enemy. Everyone was too polite to tell me how bad my tactics were though.. they just quietly ignored me ;)
Sam : of course, within about 10 turns of the game starting, my hillock was swarming with bad guys

Is it true what they say about Buddy Holly’s car?

Jason : Speaking of bad positions, and I ask this for anyone who’s lost more than five gangers in the same car at different times – some cars are cursed. Are some cars cursed? Would you tell us if some cars were cursed?
Sam : Heh. No, cars aren’t cursed. I probably would tell you, in fact it’s a nice idea maybe I’ll do it ;)
Jason : Oops.
Sam : doing some form of special stats for cars is quite an attractive idea, it’s a natural extension of what we do with gangers already
Sam : and would be relatively easy to do, not relying on graphics
Sam : it would give a whole new world of gathering for the ‘gather everything’ players
Sam : and a whole world of stories for the roleplaying players..

Developing a one-man MMO. And stuff about ‘design vision’.

Jason : I guess we can segue into more the industry/developer centric questions:
Jason : Not many developers can lay claim to having developed an entire, working, MMO by themselves. (In fact, I can’t think of any) What was that like?
Sam : it was a lot of work
Sam : it was actually a very conscious decision too. I had been involved in various business ideas during the dotcom bubble of 1998-2004 and I learned how things was fail when you’re relying on other people, especially when your work is speculative and not funded by anyone external
Sam : I didn’t want DW to ever turn into a negative thing for me, because that would make it a certain failure
Sam : Also, I made sure to pick a game design that didn’t rely on lots of custom artwork or content.
Sam : Cars are animated by physics, not by artists. And the game has a large slice of sports-sim, which is basically run according to rules, leagues etc. rather than requiring (as, say, World of Warcraft would) lots of custom content
Sam : so it was definitely a case of picking my battles carefully, as a lone programmer and quite a weak artist
Jason : You had, almost, complete creative control over your work. And actually, with the advent of Kickstarter and other crowdsourced games, you are a part of a new age of indie gaming, eschewing the help of a publisher and, in general, building what you and your fans want. How well did your original ideas survive the first glimpse of what your playerbase actually wanted?
Sam : I think the core original ideas have carried though very strongly actually. Few, if any, of the major components of the current game were not in the original design in some form.
Sam : On one hand this is because the Internet allows us to bring together groups of like-minded people. You don’t so much have to design to a demographic, as design for yourself, safe in the knowledge that there are plenty of others in the world with similar tastes
Sam : I did however have some soul-searching early on
Sam : the first few months were tough, when I had done racing leagues and deathracing leagues, and no-one was playing
Sam : I had to bite the bullet and throw away a couple of months of work and completely change the league systems, to allow casual gameplay rather than playing to a schedule
Sam : after that the playerbase slowly started to build, and we went into closed beta for a few months
Sam : but wilderness combats were the big breakthough of course

Crowdsourcing. An unlikely opportunity to get philosophical.

Jason : Is crowdsourcing a fad? I’ve heard some people are suffering from funding fatigue. Is there staying power there?
Sam : I don’t really know! I’m not really an expert at these things. I think crowdfunding will probably fade somewhat, it’s got to come out of its honeymoon period after all. Probably there will be some high-profile flops and the public will get more critical about what they fund. But the concept is very solid I think, it’s going to be here to stay. People just *love* to feel that they are directly involved in something creative, rather than merely being passive customers.
Sam : We all want to be creative, it’s part of the human response to mortality (that’s a large part of why I did DW, I call it my midlife crisis LOL)
Jason : Will we ever see an “indie” AAA title or a big developer without a publisher?
Sam : the categories are blurred already, I think they can blur some more!
Sam : But.. eh, I’m not an expert at this stuff. You wanna be asking Valiance not me ;)
Jason : Valiance?
Sam : he used to play a lot. Nicholas Lovell.. [Gamesbrief]
Jason : Nice
Sam : yeah it’s an excellent website

Textual gaming

Jason : There’s a lot of text in the DW descriptions… do you think text-supplemented games are dead (Fallout 1, Fallout 2, Wasteland)?
Sam : No, I don’t think so. I think the recent trend is towards ‘anything goes’. Different styles of games can co-exist. It’s a much better situation than we had in the late-90s and early-2000s where graphics trumped everything
Sam : as I said above, I think smartphones and casual games are a major reason
Sam : I think if Minecraft were released in 2005 it may have flopped
Sam : anyway, text descriptions are way better than graphics alone. It would be impossible to get as much detail into pixels as we have in the DW critical hits table

Hardware requirements. In which Jason politely reigns Sam back in again

Jason : Back to the game. You could easily run Dark-Wind on a netbook. I myself have been running it on a Pentium 4 well below your minimum system requirements. Do you see this changing as time goes on and content/features are added?
Sam : Very little, if at all.
Sam : I made a small change recently, I made the game client handle much more skidmark decals than before; this was for the tyre tracks in the new snowy maps. This is the sort of thing that was originally limited for the sake of not overloading player’s hardware, but it’s only a small change.
Sam : I think some of the newer maps might cause lag trouble in certain spots, but people seem to be able to work around it anyhow by keeping the camera low. A turn based game can be quite forgiving.

Pricing models

Jason : Like you’ve said, Dark-Wind has had many features added after the fact (Game modes, pedestrian combat, entire cities) and all of it has been free (other than the relatively inexpensive “monthly” fee for the full feature-set) What is your opinion of paid DLC?
Sam : I think it depends on your game and player base. Not necessarily a bad thing in the right context.
Sam : Games like world of warcraft probably have to use that model to get more money out of people
Sam : But DW has a very loyal player-base, some of whom have continued to pay me for several years. That deserves some loyalty in response.
Sam : The DW player-base is too small for me to start get greedy with anyhow ;) But it *does* make enough that I feel good about it and I’m happy to continue to put effort into

The end of Darkwind?

Jason : Do you see DW as having a shelf life, or as a UO type game that will still be running after 15 years?
Sam : I think it will be running for a long time, I wouldn’t be too surprised if it were still limping along when I retire!
Sam : Two major reasons for this:
Sam : 1.. It’s unique. Players get bored and leave (which is normal) but they very often come back later, maybe even 2 years later. This is because, I think, there is no other game the same. If someone leaves world of warcraft they may never come back because 200 other games give the identical experience. Not so with DW.
Sam : 2.. It’s cheap to run. My costs are nothing more than a single server in a server farm. If I only had 10 active subscribers, I’d be breaking even.
Sam : I guess related to point (2) — it plays out quite nicely as a single-player experience, so it’s unlikely to implode and collapse when it drops below a critical mass. At least, it’s less susceptible to such a thing than a more traditional multiplayer MMO might be

Regrets.. I’ve had a few… (snarled in the style of Sid Vicious)

Jason : Do you have any regrets about anything implemented?
Sam : only regrets in terms of wasted effort
Sam : there were a couple of times actually when there was trouble over new features
Sam : that was a low-point.. I added in electronically-controlled weapon misfiring during certain autora conditions.
Sam : But I wanted the players to figure out the conditions themselves, so I told them nothing.That was a bit dumb…
Sam : but no major regrets, no

More about the future of DW

Jason : Digging further into the future of the game, you said “Into the Ruins” will be a pedestrian-based scouting of the ruins of Evan (the burnt-out ruins of the American Southwest and surrounding areas) What are your plans for “Into the Ruins”?
Sam : I’m not sure if Evan was ever stated as being in America
Jason : :O
Sam : But that’s not important
Sam : Into the Ruins is something I should have finished long ago.. it turned out to be more complex than I expected, and it required first that I create a more details system for ped-items. But that turned out pretty complex too. Hmm.
Sam : But.. ideally… Into the Ruins would be like a turn-based ped combat game where you have randomised maps /mazes filled with danger and treasure
Sam : Quite tangential to the idea of car combat, but then again DW has already turned into a big sprawling game so it’s not a major surprise
Jason : Recently you implemented the town of Morgan, a harsh place where only the strong (figuratively again of course – driving, gunning, scouting and other skills factor in much, much more) can make the trip, much less survive there. How do you plan to make Morgan different?
Sam : It’s important to make it different, for sure. We have learned that from other towns.
Sam : I have taken ideas from the player-base mostly on this one. I never envisaged a snowy region, that was viKKing’s idea – and since he was good enough to start designing the maps, who was I to argue?
Sam : The current idea for Morgan is that it’s an isolated small town under constant attack from local pirates. So the players have to gang together and defend it, or else lose their stuff. But by defending it they gain extra training.
Sam : I’m not sure that it’s working yet, but we’ll take stock and tweak it fairly soon I think
Sam : If other ideas come along, I’ll consider them. That’s the way Darkwind is.. I guess I’m a facilitator as much as a designer at this point.
Jason : Hah
Sam : maybe that’s even ahead of its time and is one of the ultimate routes that crowd-funding leads to! LOL.
Jason : From my perspective, we can only hope
Sam : I know that it’s one of the thing that many DW players do like about it, the fact that they can actually influence things and supply artistic content etc. It’s a win-win really.

Darkwind: Scavenger – achieving DW’s original ‘design vision’?

Jason : Scavenger is the hardcore mode of Dark-Wind, an already hardcore game. In scavenger there is no money; no car rentals for scouting (you’ve got to win your first car at ‘Amateur Night’); and food and water are hard-fought, can’t be bought from towns, and necessary for survival. I’ve heard it fits more closely with how you first pictured Dark-Wind; currently is scavenger how you originally envisioned it? And is it your ideal Dark-wind?
Sam : In some ways, it would match my original idea yes
Sam : But I don’t think my original idea has any particular claim about bring “more correct” or “more valid”
Sam : As I said before, there were some glaring naivities in my original ideas
Sam : A game is a compromise of vision versus fun; realism versus playability
Sam : I don’t know what my ideal DW is today. There’s probably several of them, and they’re pretty much incompatible. Certainly DW:Scav is *one* of them
Sam : it’s naive to think that many people will be happy to play a game for an extended period of time if they keep getting bombed back to the stone age. Some people, certainly. But not many!

Characters in DW and Singleplayer DW

Jason : Dark-Wind as we play it is rather unique in that most of its players make up the who and why of their characters – it’s almost akin-to but is probably more attachment-inducing than a game of X-Com that lasts for years. If or when you make single-player cars-with-guns, how do you see the characters playing out? Will it be more story-based?
Sam : No, I think it will largely be similar, for the same reasons.
Sam : A simulation-driven game is one that is quite feasible for a small development team to make, as it doesn’t rely on lots of custom content
Sam : Although, one of the ideas for the single-player game is that players would be given a story editor module, so they could create and share scenarios. That’s feasible as a route for more story-based content.
Sam : I’d love to put more psychological depth into the characters, either in DW or in the singleplayer version ( if it happens ).
Sam : I never played Dwarf Fortress, but the psychological models of the dwarfs sound really cool .. but still fundamentally simulation-driven

Highpoints as the creator of Darkwind

Jason : From the earliest design daydreams to the players slugging it out in deathraces and special events which part of game development brings, or has brought you, the greatest satisfaction?
Sam : The single greatest moment, if I had to pick one, would probably be the first time I read “the Birth of Deathracing” posted on the forums by Korivak, back around Christmas 2006. We were still in beta
Sam : I was like… “wow, this is really well written.. this fleshes things out far more artisitcally than I could have.. and yet it wouldn’t have been written without me”
Sam : There’s also the fantastic work that many different players have put into the game, applying their own particular skills. viKKing – my right-hand man in the early days, and a fine mapmaker; Bastille – more artistic than he might realise; Dr Mathias – a talented artist and writer; Fifth – please finish your epic DW fiction, it’s awesome!; the other ‘offical’ fiction by JKWPrime; several car-skinners of note: JeeTeeOh, goat_starer; voluntary artwork from Tinker and others; the dudes with the cool voices: JD Basher and Taskmasterpeace; the Wiki and Vent guys: Marrkos and TEC; the guys who relentlessly push the rules forwards: Lord Foul, Jimmylogan, ninesticks. The ultimate long-term DW fans: Latte and Longo. The lifelong friends I have made and met IRL due to the game: goat, nine, Valiance and BWGunner. I’m sure I have missed a few who deserve mentioning, for which I apologise!
Sam : there’s lots of little satisfactions too, of course. Unsolicited “thank you” PMs from players, stuff like that

Words from the wise

Jason : What advice would you give to a young programmer who’s just starting out?
Sam : that’s a tough one. I actually meet young programmers who are just starting out all the time, I teach them!
Sam : the main thing is to love programming, that’s what has kept me doing it for 30 years
Sam : if you meant a young *games* programmer, I’d say design something original, you’re not going to do anything good by making a third-rate copy of someone else’s game

Benefits of a small community

Jason : What are the benefits and drawbacks of having a smaller community?
Sam : Benefits include: it creates a very friendly atmosphere, where the developer and players get to know each other (which is a benefit to both)
Sam : Drawbacks include: it can get clique-ish/insular. And it doesn’t make much money! ;)
Sam : Apparently it’s called a “Boutique MMO” (like a Boutique hotel)
Jason : (I’ve never heard something so “bloody” called something so beautiful)
Sam : heh. It’s a beautiful exploration of the duality of the human condition, don’t ya know ;)

The Rules Council

Jason : Who are the rules council?
Sam : you’re testing me.. you think I don’t known their names!
Sam : j/k
Jason : ha
Sam : [phew, I bluffed my way out of that one]. It came about because every time I tried to discuss something, it would get lost in a clamor of voices
Sam : so the idea came up of a smaller set of players who would represent the rest in a smaller forum where it was actually possible to make decisions
Sam : it’s a thankless task to be honest. I ignore them most of the time ;)
Jason : Do you think a Rules Council would scale well in bigger games?
Sam : yes, I think it would. That’s if the game owners were interested in making stuff democratic rather than simply laying down the law themselves.
Sam : Personally I think it’s pretty arrogant to think, as a developer, you would always know best
Sam : after all, the players really know the ins-and-outs of the game, in the way its played, better than the developer

Lord Foul and PA Racers

Jason : “The players know the ins-and-outs of the game” Is Lord Foul a person or something programmed to race, by you, like some sort of Dale Ernheart’s-with-time-to-think to make everyone look bad
Jason : think he’s a racer in real life?
Sam : LOL. Actually PA Racers is, I believe, a racer in real life. And when he first started playing, he blew the rest of us away. He was beating players who had played for 24 months and who were using highly skilled characters, when all he had were 20-skill drivers
Sam : I think LF must be real, because he stumps up real subscription fees!
Jason : :D


Jason : So Sam, one for the road: Really, how old is Dexter?
Sam : I think he’s probably perpetually 45. The oldest possible person we can ever imagine in Evan.


Jason : Thanks for sitting down with us Sam. It’s good to talk with a dev who really ‘gets’ his audience. Now we’ll have to have the Euro DW players go out and chain you back up to to the development station. (There’s only a few possible ways to squeeze a mmo out a single man, but I digress.)
Sam : It’s been a pleasure, thanks yourself! Not that ‘getting’ the audience has made me a mega-success or anything ;)
Jason : And with that, we’ll let the esteemed Dr. get some rest. Thanks Again!
Sam : Thanks! Looking forward to reading it :)
Sam : We haven’t had a player-driven interview recently, so it’ll be good to add to the podcast ones that JD/Task/toecutter did several years ago


Dead By Dawn

I have been working on various gameplay bits.. searching, recoil & recovery, action states. Also the zombies now attack, and eat you when you die (heh).
Next up, I’m working on the inventory system and on controlling multiple characters. The idea is that you’ll have to co-ordinate several characters at once; some searching while others defending, etc.

Dead By Dawn splash


GUI Texture Atlases in Shiva

As you probably know, it’s important to use Texture Atlases for efficiency reasons on mobile devices. The idea is that you pack lots of textures into one big one, and then use UV offsets to define which region of this large texture to display in your HUD components. This means that only one texture has to be referenced by the graphics hardware. But it can be a bit fiddly calculating the UVs, especially if you want to add new textures to it later.

I have put together a nice workflow for this, so I thought it might be useful for other people too..

Step 1: Create your texture atlas. I use a program called Texture Packer for this, which combines your textures into a single PNG and also exports an XML description of it (which we’ll need later; we could of course manually write the XML but it’s a bit more work that way..)

Texture Packer

Step 2: Write or export your XML. My Shiva code a bit later will assume the following format, which is what Texture Packer gives us. It simply encodes the names of the images (sprites), along with their positions and sizes in the atlas.

<TextureAtlas imagePath="ZS_icons.png" width="512" height="512">
<sprite n="backpack" x="204" y="2" w="160" h="186"/>
<sprite n="rotate_left" x="366" y="51" w="48" h="47"/>
<sprite n="rotate_right" x="416" y="2" w="48" h="47"/>
<sprite n="search" x="366" y="2" w="48" h="47"/>
<sprite n="shotgun" x="2" y="2" w="200" h="86"/>

Step 3:
Import the xml file and texture atlas in to Shiva

Step 4: Create your HUD. Anywhere you want a texture out of the atlas, just set that HUD component to the Atlas texture (it looks a bit weird at design-time..)

HUD at design time

Step 5: Add an XML variable to an AI, and set it initialised from the imported xml. (I call my xml variable xmlZS_icons, and hard-code that in the code below)

Step 6: Add the following function to your AI:

function MyAI.SetUvsFromTextureAtlas ( sComp,sIcon )

local r = xml.getRootElement ( this.xmlZS_icons ( ) )

local imgWid = string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( r, "width" ) ) )
local imgHgt = string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( r, "height" ) ) )

local c = xml.getElementChildCount ( r )

for i=0, c-1 do

local e = xml.getElementChildAt ( r,i )
if ( sIcon==xml.getAttributeValue ( xml.getElementAttributeWithName ( e, "n" ) ) ) then

local uscale = string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( e, "w" ) ) ) / imgWid
local vscale = string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( e, "h" ) ) ) / imgHgt
local u = string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( e, "x" ) ) ) / imgWid
local v = 1-( string.toNumber ( xml.getAttributeValue ( xml.getElementAttributeWithName ( e, "y" ) ) ) / imgHgt )-vscale
local comp = hud.getComponent ( application.getCurrentUser ( ),sComp )
hud.setComponentBackgroundImageUVOffset ( comp, u, v )
hud.setComponentBackgroundImageUVScale ( comp, uscale, vscale )



log.message ( "Unable to find icon '"..sIcon.."' in texture atlas!" )





Step 7: And finally, whenever you instantiate your HUD, call the following for each HUD component that’s included in the texture atlas:

this.SetUvsFromTextureAtlas ( "MyHUD.MyComponent", "sprite_name" )


final result


Dead County – work in progress

I still haven’t decided on the name for this game, so “Dead County” is a working title. I have been working on the zombie A.I. (it’s very easy to make them look dumb, heh) and throwing in some physics-controlled objects to add to the fun. It’s a pity my gun doesn’t work yet..

Edit, Aug 16th: now the shotgun works.. :-)


Zombie Graveyard

I have been having fun scratching around with some ideas for a 3rd person zombie survival game, in which you’ll progress through a series of randomly generated towns, and you’ll have to find resources and items, meet new characters and level up their skills, and all the while the zombie threat grows harder and harder. Maybe the game ends when all playable characters are dead.

So yeah, first step is algorithmic town generation. I have bought some nice road models from turbosquid and a bunch of buildings from dexsoft, plus a lot of stuff I had already from Darkwind (including tombstones, buildings, trees) and here’s a first cut at a random graveyard.. the home of the zombie spawnpoints.

zombie graveyard

A bit more work and we have the basis of a town generation system. The roads are put in first, followed by the graveyard and buildings. The orange areas show ‘free’ regions; the idea is that we search for random free space for each object, starting with the biggest and finishing with the smallest.