Game Design, Programming and running a one-man games business…

The Democracy 3 Compass

So here is a half-finished feature I’ve added to the main menu for Democracy 3. It’s a chart showing the last 50 election wins you had in the game, with the icons representing the countries you were playing at the time, and they are printed onto a left/right liberal/conservative axis so you can see what the state of the nation was at the time. In a way, this is a clue to your own political opinions and prejudices, as presumably you will gently be nudging all the countries in a similar direction.

compass

Next up: finding a way to populate the chart with the average positions of any of your steam friends who are also playing the game…

Some optimization tips for game programmers

I’m enjoying myself with some optimizing today (yeah I’m weird like that). So I thought I’d jot down some of my tips for making your game faster. These are general, not language-specific tips.

Never run code you don’t have to run

Seems obvious but few people actually do this. For example, in democracy 3, the simulation calculates the popularity of each policy by asking every voter if they benefit from it. That question is complex, and there are a few hundred policies and 2,000 voters. This takes time. Solution: I only ask them about a policy if I need the answer right now. Some policies can go a dozen turns without the player ever checking their popularity, so why keep calculating it?

Batch Stuff

If you have a dozen icons that are always drawn one after another on the same screen, stick them in a texture atlas. If you are 100% they will never overlap, then draw them in a single draw call. the less texture swaps and draw calls, the faster your code. This is trivial to do in 3D, an absolute nightmare to do properly in 2D, but it’s worth it.

Cache Stuff

If you have a variable that is complex to evaluate, evaluate it once, then cache it until it changes (we tend to call that setting it ‘dirty’). If there is some data that is going to be accessed a LOT, then make a local copy of it. And if you have a lot of stuff to write to disk, to the same file, buffer it. Writing to or reading from a file is slow, especially if you are going to do it a lot. Reading in a single file is much quicker than opening 200 of them one after another.

Don’t use sqrt()

Do you ever use sqrt()? never realised how scarily slow it was? Most of the time you can keep the squared result and use some clever tricks to not actually need the sqrt() result. If you were going to get the sqrt() and compare it against a value, just multiply the comparison value by itself and check it that way instead. it’s amazingly faster.

Use the right container class

Sometimes you will use a list where a vector will do. The vector is MUCH faster. And you know what is faster still. I mean REALLY fast? An array. If you really need speed, and the array size won’t change that often, allocating an array of items is much faster and is worth the overhead.

Re-use objects

If you have a collection of objects that keep getting created and destroyed, you want to wrap that up. Stick a factory object around them to handle their construction and destruction. That way, you can just set them inactive on destruction, and save yourself the hassle of the creation and destruction when it comes time to re-use them. Setting a single flag to say an object is ‘dead’ is way faster than calling a destructor, and resetting is way faster than a constructor.

Obviously there are lots more tips, and you should get a decent commercial profiler. That PC you develop on is a super-computing beast. if your game takes more than a few seconds to load, you are being sloppy.

 

Redshirt developers log…

First gameplay footage, as I recall. here is mitu explaining how to suck up to the boss…

Redshirt alpha screenshots

Ok…so today marks the day when we send out press releases to a bunch of journalists about Redshirt. (If you have somehow been missed email me). For those who haven’t been following progress on the game, Redshirt is a sci-fi social-networking life-sim comedy game by The Tiniest Shark, which is being published by me. It’s the first time I’ve published another developer’s game. yes I have become THE MAN.

redshirt_Logo_transparent_500

As well as sending out press builds, we have a bunch of shiny new screenshots to share with the world, and obviously news on the game will speed up now we are in alpha, heading towards beta and pre-orders. Without further ado…click to enlarge…

Don’t forget to check out (and please LIKE!) the game’s facebook page at https://www.facebook.com/redshirtgame

Staggered Game Release failure

One of my plans with the game I’m publishing ‘Redshirt‘ was to have it all set up nicely so that it launches in-between my own game releases. I’d therefore keep the positech games name and website alive in every-bodies minds while I huddled in a corner typing away on my next masterpiece. The thing is, no plan survives contact with the real world, and with some stuff going faster than expected, and other stuff going slower, and ‘events dear boy,events’, it turns out that Democracy 3 and Redshirt are going to be close to shipping at almost exactly the same time.

It’s so close that I actually got voiceover for both games on the exact same day. I’m interleaving emails to the press about one game, with emails about the other. It’s CHAOS I tell you. CHAOS!

Obviously I’m sure it will all be ok in the end. Redshirt is looking really cool, and it is crazily crazily addictive already. It requires balancing, as do all games towards the end, and there is the inevitable ‘things act differently on this PC’ nonsense that us PC developers absolutely LOVE.

redshirt_Logo_transparent_500

We will be showing off redshirt to the wider galaxy very shortly, so expect screenshots and more info on the game very soon. Also expect lots of puns about tentacles. I’ve already added a link (for widescreen layouts) to the redshirt site from www.positech.co.uk. I only do this at the last minute, because I tend to prefer to funnel eyeballs towards opportunities to give me money NOW :D