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

The games programming advice that’s impossible to describe.

Occasionally I see some interesting posts on reddit or gamasutra or some other dev site where programmers are asking about stuff to do with game development, and I find myself thinking ‘these aren’t the things you really ned to know’, but because its such a DIFFICULT thing to articulate, I never even try. I’m going to try now…and it will be messy.

 

A long time ago, when the world was in black and white and you could get your milk delivered even in the cities, I went for a job as a game programmer with a smallish UK game studio. I didn’t get the job. I remember in the interview being asked about my code, and in some vague way trying to explain that I knew what I was doing and a proper software developer. I waffled really badly about how giving sensible names to variable meant that I knew what I was doing and not some n00b.

Hahaha.

In my mind…this:

for(int counter = 0; counter < total; counter++)


Made me so much better a software engineer than

for(int x = 0; x < total; x++)


That just goes to show how much I had to learn. The real problem is that the stuff you need to learn is big ‘hand-wavey’ stuff that its really hard to explain, let alone teach! if you haven’t already read a book like Code Complete, Now would be a good time. I will try and explain the sort of stuff that it really helps to learn, and it will be vague and awkward, and hopefully that kind of makes my point about how hard it is to grok this stuff.

I have a class in my latest game called GUI_Tile. Its the visual representation of an actual tile in the game world called SIM_Tile. Each SIM_Tile has a GUI_Tile, and anything that is on-screen is handled by GUI_Tile. In order to draw my world, I go through all of the GUI_Tile objects and call draw on them. Actually, thats what I used to do, but it turns out there are a lot of them and thats fairly time consuming. When I profile the code, looking at where the time is spent, I realize that a lot of it is not actually directx calls, but its transform stuff, and scaling stuff, and working out the sizes of sprites based on some animation they are doing, and their offsets and whether or not they are even on-screen given the current camera position. The actual DrawSprite() bit of each GUI_Tile call is only the last statement…kind of a footnote.

While all this is going on, the other 7 effective cores of my CPU are chatting about whats on TV and picking fluff from their navels.

So clearly, I should find a way to multi-thread all this, even though I’m using Directx9 which is effectively single-threaded.

Soo… I could create a new thread at the start of the app, and make that my directx render thread. it could then do nothing but make render calls, and all the other stuff could happen in another thread, thus allowing me to double up on what was going on. To keep things from going crazy, and me updating a sprites co-ordinates just as directx rendered it, I need a hard STOP! (or mutex etc) at the time I start rendering, but it will still allow some overlap surely? I could carry on with the windows message handling and sound/input processing in thread 2 while thread 1 was still rendering the previous frame.

Or

I could split the GUI_Tile::Draw() call into GUI_Tile::PreDraw() and GUI_Tile::ReallyDraw(). If all of the stuff in the PreDraw() is self contained or ‘read-only’ (in other words that function never changes the value of any data outside its own object), then I can run a whole bunch of those at the same time. I can keep my directx in the main thread, but pass all the tiles in bunches off to 7 other worker threads to do PreDraw(), then when they ALL finish, I can just quickly loop through the Draw() calls, which are way faster.

Or

I could not do a lot of this transform stuff or drawing stuff each frame anyway. I could use a dirty-rects system, where when I render a frame I keep a copy of the whole thing in an offscreen buffer. I then only bother calling Draw() on those tiles which I know have actually changed or done anything. That way I’m massively cutting down on the number of Draw() calls I make, and I can keep the entire thing in one thread and thus way simpler.

Or…

etc.

The real thing you need to learn to be a decent game developer, is which one of those solutions will work best for this game, with this hardware, with this API, with this data. Coding any one of those solutions takes TIME. Debugging them takes more time, and profiling and analysing to see which works best takes more. Maybe having 8 threads all running is actually slower than just one (this can happen if you do it badly). Maybe a dirty rects system falls apart dramatically when zooming and scrolling. Maybe assuming PreDraw() is a nice self contained function is a bug-prone disaster waiting to happen in obscure and impossible-to-debug ways.

This is the real hard stuff, and the main reason its real hard is that its very difficult to get on top of this sort of thing until you have done it a LOT. If you have programmed, for example, a sound engine…well done. Take a bow, its honestly not that easy, and I bet you learned a lot. You have programmed your FIRST sound engine. Now delete all the code and program it another way entirely. then again, then again, then again. NOW, you know how to program a sound engine. you know why method A is slow, why method B is buggy, why method C is hard to maintain, why method D doesn’t scale, and method E Is awesome, but only on Playstation 4.

This is why the top jobs often to go to coders with experience, and why the sheer amount of code you have written and the number of hours you have been typing code really does matter. Being a good programmer is rarely about those things that are often bandied around like ‘always comment your code’ or ‘use descriptive source control commit descriptions’ or ‘use this syntax in your code’. Its mostly about the big ‘code architecture’ decisions. The way you lay out your code, the overall designs, the thinking behind how the whole process snaps together.

The most efficient coding you ever do is probably with a pen and paper, or a big chalkboard on the wall. When you have done this a LOT, you can do that in your head, but that takes decades. The more you code, the better you get.

 

The movie industries broken business model

I don’t understand the people who run movie theaters/cinemas…

In the year 2016, I have a bloody good 40″ TV in my living room. It has a perfect picture, and with Blu-ray, its as good as the movie theater. I have multiple hi-fi speakers and a subwoofer, and don’t really miss surround sound. Also I have a lot of stuff the movie theater does not have:

  • A pause button
  • Complete control over volume.
  • Complete veto on who I watch the movie with
  • Complete scheduling freedom
  • Total control over lighting and temperature.
  • My cats can be with me.
  • Zero travel time, zero parking issues
  • Reasonably priced food
  • The best seats in the house.
  • Probably cheaper.
  • Ability to fast-forward the trailers and ads.

image1

By any conceivable measure, watching a movie in my living room is a superior experience to going to a movie theater. The movie industry still tries to get me to go with the two tiny…tiny..advantages they have:

  • A short (and shrinking) period of exclusivity
  • 3D!

As someone who is stereo-blind, the second advantage is a disadvantage. The first….well thats all they have. Frankly, its not enough. 3D is generally not making movies better, its been adopted to help combat piracy, in the ridiculous assumption that movie piracy is a bigger threat to the business than the adoption of high-speed streaming, fiber-optic to the home and cheap big flat screen TVs have been.  How could they do a better job of all this? Here is what I would do…

Take a lesson from ‘secret cinema’ and make going to see a movie an EVENT, not just an inferior experience…

  • I’d dress up the movie theater staff as characters from the big new hit movie
  • I’d sell memorabilia, toys, t-shirts, posters, everything…associated with the movie at the theater. Surely this is a no-brainer?
  • I’d have a bar…a decent bar, with cocktails and drinks named after movie characters, big screen TVs showing ‘the making of’ and other fan-content so people can get hyped with a pre-movie drink.
  • I’d massively encourage cosplay. Best outfit on each screening gets their ticket price refunded + posters & swag.
  • I’d increase the price of the ticket. This is an event, not just a movie.
  • All seats are premium seats, All seats are comfortable and adjustable.
  • Give everyone the option to pay extra and take a blu-ray of the movie away with them the moment the movie ends.

storm

Maybe that wouldn’t work, maybe it makes no business sense. But as someone who went to secret cinema (expensive) to see Dirty Dancing (not a movie I care about) and had an AMAZING time, and would easily pay double to go again… I look around me and I see movie theaters that are almost always 90% empty, and secret cinema going from strength to strength. People want experiences now, not just an inferior viewing of a movie.

You always have to give people a reason to buy your product. The movie theater has virtually none right now.

 

Donating Democracy 3 revenue to War Child

Watch this video:

Starting Today, and running for twelve days, Positech is donating all its steam revenue from the Democracy 3 franchise to a charity called war child. Thats the full price of each game, minus steams cut.  Hopefully we will raise about $20k. As gamers, we spend a lot of time (me included) shooting guns in virtual wars. Lets spare some time to consider the impact of real; life wars that are happening right now on children around the world.

Things are actually getting better.

I know its trendy to moan and complain about life, and the government, and how things are SO BAD and are GETTING Worse. I used to do this when I was 16 too. Then years later you look back on life then and realize things are definitely NOT getting worse, and it was a combination of selective news-reading / alcohol / puberty / political bias that makes you think that way.

Everyone who is young thinks things are getting worse and they have never been this bad. In the UK at least…that’s probably not true. I’m not saying the UK is perfect, far from it! But I took the time to research some stats, and went only to official stats sources, no spin or selective reporting. here is what I found.

chart1

chart2

chart3

chart4

chart5

So not everything is bad! Remember to look at the big picture when you think ‘things are getting worse, its never been so bad!’. Everyone thinks that in the short term.

See…I can do optimism. I just generally choose not to :D