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

If anyone can do it, everyone will.

Every now and then I come across a story about how mid-tier youtubers are making an absolute pittance, or that indie bands on spotify earn less than minimum wage, or that writers (like my wife!) can expect to earn a really trivial amount for what they do.

This is totally and utterly expected, and its down to barriers of entry, of which there are a few.

Barriers to entry is an economics term that refers to all the stuff you need to have to produce a certain product in the market. Some industries naturally have small barriers to entry (busking only requires a guitar, for example) and some have huge barriers (spaceships, cars, silicon chip production). Generally speaking, barriers to entry are very bad, from an economics point-of-view, because high barriers-to-entry lead to ‘abnormal profits’ by people in that market, as its difficult for newcomers to enter the market and bid down the price of the product.

It might seem that this explains why indie game devs rarely make any money, because the barriers to entry for indie dev are tiny. You need an office chair, a laptop, an internet connection, and…a rudimentary skill in programming and game design. Thats a LOT of people, and its WAY more than it used to be, now you dont have to code your own engine and dev-tools are affordable.

SIDE-NOTE: YES amazingly cliff is aware that there are millions, if not billions of people who cannot afford a laptop and broadband. Well done! 10 internet points for you! But this blog post isn’t aimed at solving inequality. Not everything on the internet is aimed at everyone, or is a political statement!

Anyway… indie game dev does indeed have super-low barriers to entry and this should mean that nobody in that industry makes much profit, but hold on! some of them do! Jonathan Blow! Introversion! Me! The Factorio & RimWorld devs… how is this possible?

Barriers to entry can include personal ones as well, not just financial requirements. Sure, anybody can buy visual studio (my dev tool of choice, about $500), the same chair as me (aeron, about $1k) and a decent PC (maybe $1,500 tops?). They can then decide to make an indie game. This will not be profitable, as there are a LOT of people in this green segment below…

Some games are technically much easier to make a first-game in than others. Platform games come to mind, as do arcade games. If you are using unity or similar, maybe a primitive FPS. Some genres are harder. Strategy games are harder, as are RPGs, Simulation games can be really hard. By choosing one of the ‘harder’ genres, you are already putting up barriers to entry to prevent your market value being competed down. Of course your job just got harder, but thats to be expected. There are fewer people in the white segment below.

Where it gets more interesting is in leveraging barriers than cannot easily be broken down by any means. That comes down to what makes you…YOU. Leveraging that unique venn diagram of skills and interests that makes you capable of making the game that YOU can make, but its unlikely any other dev can.

In my case, studying economics at LSE, and the son of parents who were both trade union reps, someone who got taken on ‘fun trips’ to the Trades Union Congress and Labour Party conference as a child (yes really), plus an aptitude for maths and logic (and clearly being on the autism spectrum) means that my venn diagram screams MAKE COMPLEX POLITICS SIMULATIONS. There are a handful of people in the white segment below. maybe me and Brad Wardell and half a dozen others?

Now in theory, anybody could try to clone Democracy 4 and force down my profits, but in practice its hard because you have to REALLY be a politics geek to spend the time and effort to make that sort of game, and the coding challenge is sufficient that it still gives me headaches after 39 (yes really) years of doing programming. Plus I have a special super-power that allows me to be even better suited to that exact project:

I’m pretty much a centrist. Politically I’m slightly right leaning on economics and slightly left leaning on social issues, but generally speaking I’m a moderate. That means I can sit down and have a meal and a chat with a hardcore bernie sanders supporter OR a trump-supporter, and get along with both as people. That means I’m not trying to have a big political agenda with my politics game, which broadens its appeal. (I’m not going to attempt to add another circle to that diagram…)

Every extra circle you can add to your indie game dev venn diagram of uniqueness™ is going to boost the probability of you earning decent money. Of COURSE…. you still need to work hard and make a great game, and make it appeal to enough players and do the other 999 things. This system only helps you maximise the returns WHEN you have an idea, and execution that results in something people want, and buy. I still think its worth keeping in mind.

Pak files

I just added pak file support to Democracy 4. Its something I already had coded for an earlier game, but I had to do a bit of fussing to get it to work properly with democracy 4.

Pak files are basically big phat files that contain other files inside them. If you are a new developer, you probably have no idea they exist, because you probably use unity and AFAIK they handle it for you. Pak files are pretty old school, as I recall Doom and Quake used them (maybe called wad files), anyway the principle is pretty simple:

A pak file contains two sections, an index that tells you where all the other files are inside the main section, and a big phat list of data that is the contents of those files. All of this gets stuck in a single flat blob of binary data. A class exists that lets you grab the memory address of the file you want if you pass in the name of the file, so hopefully to anybody who didnt write the pak file code, using it is easy. You can read the contents of a file just like its on disk, except you have to use functions that read from memory, not ones that explicitly read disk files.

In my case, that meant stepping into the engine code, and the opengl stuff that reads in graphics files (we are only using a pak right now for dds and pngs), and just changing the contents of one function. Instead of using this code to load the data ready for creating a dds:

fread(filedata, filesize, 1, fp);

I now use this

memcpy(filedata, GetPakFiles()->GetData(pentry->StartOffset), filesize);

Big deal :D. Similar changes happen for pngs. To keep things super-simple, the old code for loading a file will run if the pak file reports it cant find that file, so you can stick a ‘loose’ png or dds file into the bitmaps folder structure and it will still get found, and the rest of the code doesnt even know the difference, which is perfect for mod support.

Most of the hassle in getting this to work was just writing some code to enumerate (that means list really…) the contents of a folder from within the pak file. I had to support this for stuff like minister profile pics, because the code previously would ask ‘what files are in this folder, I need to know so I can select a random one’, and now that code gets handled by the index at the start of the pak file instead.

So why bother with this?

Basically speed. Do you know wwhat the read speed of your hard drive is? Checking a random new one on amazon.com shows 6Gb/s. I assume thats bits not bytes, so thats 750MB per second. My hard drive is a little bit older, so lets say 500MB/second. I’ll just copy a big chunk of the source and obj files from D3 to another disk, brb…

Ok…copy speed is between a low of 1MB/second up to 100 MB/second. Wow. Thats so much slower. Why?

A HUGE amount of bullshit happens on a PC when you access files. To simplify it, it goes something like this: *deep breath* You ask to read in a file. The OS then looks up the file table to check that file exists. it then asks the security system if the current user has permission to access that file. When it gets a yes, it then opens that file, and sets attrributes so other processes will know that file is in use. The antivirus software then kicks in, and hooks into the file read so that it can check to see if that file is excluded from scans or not, and gets ready to analyze its contents. The O/S then has to use the file-table to work out where all the various scattered chunks of that file are, and start reading in each block. This means talking to the driver, and ultimately to the hardware, which may also have to check its cache to see what blocks have been cached and whether or not it has to start the glacial process of spinning an old physical drive or not (faster with SSDs obviously).

THEN! when the file read is complete, we can close that file again, notify the system that its not in use by our process any more. We can then start the process of opening the next file in our list..

You do that bullshit for EVERY DARNED FILE. But the good news is… if you have a big phat pak file…you do it once. Just once. The rest is free.

So Democracy 4 goes the extra mile, because our pak file is small (only a few hundred MB). We dont just open the file on startup, we stream all 200MB into RAM. That should take way under a second. We then have the entire file system of dds and png files in memory already, and able to be loaded almost-instantly into our engine. (RAM->VRAM is mega fast)

99% of players will not notice the speed difference. But if you have especially shit anti-virus running on a laptop, in low-battery mode, with an extremely fragmented hard drive, running democracy 4 on a train, you will be glad I bothered. Its really easy to code. My PakFile code has 263 lines in it. Many of them are whitespace or comments.