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

Skills GUI

I made a decision with Kudos 2 that I was going to get everything working and looking how I wanted, regardless of how much hassle was involved. Partly this just means changing my state of mind when I’m typing out my ‘todo’ list as I test the game. Rather than mentally editing it to take into account technical difficulties, I just jot down how to improve the game and tell myself not to worry about what’s involved. Then when I go to implement them, I just do it, regardless how awkward some things are.

An example of this was the panel that shows the players skills. This panel just sat there and didn’t have the status update balloons which flash up when you change your attributes, but when playing it occurred to me that this would be a good idea, especially on the ‘post mortem’ screen where many of them change. Making them show up at all involved a ton of recoding. Then I hit the issue that you can have a lot of skills, and they looked horridly cluttered on that post-mortem screen.

So eventually I had to write a bunch of extra code for the skills GUI that rebuilds it just for the post-mortem screen, showing just what’s changed. This is great for the player but was a bitch to code. Hopefully, if I can keep developing like this, the game will have a far more polished feel than anything else I’ve done.

BTW server is a bit slashdotted today…

Game Dev Shortage

Apparently there is a shortage of people to work in video games:

http://news.bbc.co.uk/1/hi/technology/7460870.stm

Me and some other ex-industry people I know find this very amusing. Apparently one of the issues that game developers have is finding suitably qualified graduates to hire. Here is a newsflash for them:

If the experienced people didn’t leave, you wouldn’t need the graduates

It’s sad the way many games companies work. They deal with horribly high staff turnover as a matter of course. Staff turnover is a devestating problem for a knowledge based business. A new coder probably achieves nothing of any real value for the first few weeks, little for a month or two, and is probably only really working as a games coder by the end of their first year. To becomre really experienced at the practice (not theory) of games dev takes at least 3 years. By then he (almost always a ‘he’ sadly) is sick of his job and often keen to leave, and so the company promotes everyone and hires a new graduate.

Staff turnover is always bad, but for programmers it’s unusually damaging. It’s easier to find your own bugs than the last guys bugs, especially if the last guy isn’t here to ask him what the f**k he was thinking when he wrote that stuff. If your company doesn’t adhere to coding standards, it’s even worse.

Here’s some free advice to anyone wanting to retain game coding staff:

  1. Pay the experienced devs more. They are worth more. they can find the bugs the others can’t. their code is better, faster, more stable. Don’t worry if some coders earn treble what others earn, this is very often justified.
  2. Give them a decent working environment. We stare at monitors a lot. if we need ones that cost $1,000, then that’s what we need. Deal with it. It’s worth it. Ditto chairs.
  3. Ditto PC’s. AAA games take ages to compile. if you don’t want to pay coders to sit and eat donuts while the code compiles, buy them the fastest PC’s you can get. This will *save* money.
  4. Make everyone go home at 6PM. Abolish the stupidity of the long-hours culture. If you can’t concentrate on emails after 8 hours, what makes you think that a programmer can write decent C++ code without bugs after that many hours in a day. Less tired coders == less bugs == faster dev time, and happier developers.
  5. Train the devs. If they want half a dozen C++ book on expenses, let them have them. It’s trivial in cost terms in terms of increased productivity. Most coders *want* to learn. so support them.
  6. Either give developers individual offices, let them work from home, or get everyone noise canceling headphones. Maybe 1 in 10 programmers can work well in a busy noisy office, but the other 9 will be working less efficiently than they would be in a quiet office, and getting annoyed about it

Of course, many companies don’t want to hear any of this, because to many guys in suits who aren’t coders, the cheap graduate in jeans sat slouched at his keyboard is doing the same job as john carmack. why the hell would they treat any of them better than the cheap graduate?

Minimizing Texture Swaps

Heres the other ‘big thing’ that sometimes causes 2D games like mine to slow down. Not drawing too many pixels, but changing what image is being drawn from too often. Video cards are great at drawing tons and tons of triangles using the same image to copy the pixels from. changing which image is ‘active’ will cause a major stall in the video cards rendering operation and waste time. Bizzarely, AFAIK you can only have ONE texture as the active texture for any specific moment (without doing multiple textures in different ‘stages’). So regardless how many pipelines your card has, you can’t be drawing from two different textures to two different polys at once. (is that right?)

Worst case scenario:
You render 200 sprites on screen. half have texture “ogre.bmp” half have “elf.bmp”. They have to be drawn from back to front, so that nearer ones obscure further ones. They are positioned (in distance from you)

Elf / Ogre / Elf / Ogre / Elf….

Etc. This is hell. because it means changing the texture 100 times. Ideally what you would do is get the video card to sort this stuff out. You would use Z values (distance from the viewer), and send all your sprites to the card with the right Z values and let the card sort it out.

Thats easy if you have a nice modular engine where every single rendering call goes through some nice sorted system where everything drawn on the screen is esentially some offshoot of the same base object. if you only ever draw sprites, then just send a huge bunch of Z-positioned sprites to the card and click go.

Unfortunately few engines work that simply, because there is no ‘one size fits all’ drawing object. Text is often composed of thousands of 2-poly characters, best sent as a vertex buffer. Some lines and primitives are drawn using direct 3dDevice rendering calls. And some are sprites with different render states. This is where it gets horribly messy. I’m slowly, with each game getting closer to a system where I am not blindly just rendering over the top of myself and hoping for the best. I can at least now bunch up a load of sprites called from different places, and have them drawn with a single call. What I don’t have is a perfect system that auto Z-sorts my sprites by position and texture, and makes the most efficient calls. maybe some 2D games have such a system, but I’m assuming most of them just don’t do enough fancy drawing for it to be an issue (or they ignore backwards compatibility with slower cards).

If I was a bigger company with a dedicated graphics programmer who just worked on the engine, I’d have a better system, but I’m still a one-man show doing everything, and there just isn’t time :(

Why use Directx7 (and dead links)

My games use directx 7. Not 8, 9 or 10. SEVEN. That is OLD. If you have windows XP and never installed anything, you already have Directx7 (or later, which is fine).

Why do I do this?

Several reasons. Firstly, DX7 is the version I learned when I first wrote a reusable graphics engine for use in multiple games. Re-writing an entire engine can be a slow process. Don’t get me wrong, getting it to WORK, is not a big deal, but getting it stable, bug free and (essential for an engine) FAST is very slow work. I know DX7 very well, I have optimized it to death, and know my way around the API really well.

Secondly, DX7 is all I need. I don’t even do 3D games, let alone ones using bump mapping and pixel and vertex shaders. I don’t stream geometry or use mip maps, or do multithreaded vertex processing or anything clever like that. DX8 and 9 *do* achieve some simplification of code, but don’t add anything I need.

Thirdly, DX7 means everyone who buys the game will have drivers that support the game. I don’t need to package the game with the directx installer or worry about such things. Some people playing indie games on laptops have very low spec cards, and you are best off sticking with DX7 if you can. A LOT of casual games use DX7.

The thing is, Microsoft REALLY don’t like this. Obviously they try and push you to use the newer versions, that’s natural, but it’s almost like they are insulted and annoyed if you want to stick with DX7. It is *impossible* to find a download of the directx7 SDK. Microsoft removed it from their website, including all earlier versions. They want to FORCE you to use the new stuff, even if its just pure hassle with no gain. After all, why would anyone make a game without bump mapping right?  I am rewriting part of my engine in an attempt to speed it up yet again, and I was forced to dig out the CD that came with an old book to find some source code, written by Microsoft that they refuse to let you have any more. It’s mad. I have released a lot better games that ‘Asteroid Miner’, but if you follow a link from a website not updated since 1997 to my homepage (which has moved servers 4 times since then), to an outdated zip file containing the game in the root of my site (before I knew not to do this) that zip file is STILL there. I just think it’s rude to move files people have linked to, for no good reason. Every time I follow a link to a companies website that’s dead, I just think they are LAZY. Web links last a very long time, why encourage inward pointing links to die?

Reducing OverDraw

When you make 2D, rather than 3D games, the two things that can slow your game down on older video cards (forgetting CPU limitations for now) are State Changes and Overdraw. State Changes are basically texture changes (drawing a different image). Doing this too often can really slow down older cards. Overdraw is the problem I was looking at yesterday on Kudos 2.

Kudos 2 is fixed at 1024 by 768 res. thats roughly 768,000 pixels, in 32 bit color, or just over 3MB to draw the whole screen. Because of the way video cards work, you have a front buffer, a backbuffer and the source art itself, so this equates to around 9MB in practice. Given that even the most wonky video cards have 32MB of RAM, this is no big deal, but this is assuming you just load up a 1024 x 768 texture and copy it to the screen.

The first problem is you can’t have a 1024 by 768 texture. DirectX prefers things to be ‘power of 2’ in each dimension, so you have to have 1024 by 1024, and as a worst case, waste a lot of space anyway. That’s only a minor problem though. The real problem is what happens if we end up drawing the same pixel too many times a frame. This is called overdraw, and its quite easy to let it slow down your game.

The best way to see how bad overdraw can be is to code a version of the game that draws every image as a fairly transparent white box. See below:

That’s kudos 2, AFTER I optimised some of it. The lighter the colour, the more times that same pixel is being redrawn. Sometimes, this is legit, because I am blending two images together, so you can’t just draw the top pixel, but in the majority of cases, it’s just inefficient. You can tell that one of the worst areas of overdraw (apart from the avatar, which is pretty inevitable) is the dialog boxes. These are a pain.

My dialog boxes are drawn on top of an existing background, theoretically giving me the opportunity to ‘punch a hole’ in the background and save some rendering. The dialog itself then has a ‘client area’ drawn using an additional image, which wastes space behind it. Any buttons on the dialog then add a third level of overdraw, and of course the text, or button icons are a fourth layer on top of that. If a tooltip pops up, we are at level five, and six for the tooltip text, seven if the cursor is above that! :D.

For video cards like mine, with an insane ‘fill-rate‘, it’s pretty irrelevant (The game runs at around 200 FPS right now), but I’m determined to make Kudos 2 easily usable on a low spec laptop with an Intel video card. I don’t lose *that* many sales due to poor performance with my existing games, but I’ve never made a game that looks casual enough for many owners of low spec PC’s to play before.