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

Slipped back into graphics tartery…

Ok, so for a few days I was working on graphics stuff for GTB, rather than gameplay. A lot of this came about because I wanted some GUI in there for issuing movement orders to units, and that is mostly done now. It also looks pretty nice too. The idea is not that you will generally be issuing movement orders, because like most tower defence games, your troops attack on rails, but sometimes there is branching, and you might want to ensure a certain unit goes left, or right, so you can give them an override-path manually. My current thinking is that in the GSB style challenge battles, this just isn’t an option, so it retains it’s hands-off style for that game mode.

A bit of profiling through a lot of doubt over my claimed 400% increase, and it looks like it’s a lot lower than that :( I blame Visual studio often not realising it needs to overwrite an exe when you change configuration. pesky Visual Studio…

However, my profiling binge did point out something scary (and slowdown-inducing) which was that in some average night-time battles, I was calling SetRenderTarget about 45-50 times a frame. Ouch! This was mostly stuff like searchlights and laser beams, that render to the screen, then also get rendered to a light map for later composition and niceness. They were handling this individually, rather than being batched as they are now, meaning less that 18 SetRenderTargets per frame, and several more of those will get optimised away soon. Many of them are essential, for selection UI, lightmaps, shockwave distortion and fog of war.

The ups-hot of this is that I can play fullscreen, release-build 1920 x 1200 res with all graphics options on, at night-time, with toggling night vision on and off, explosions, lasers, searchlights, unit selection UI and range GUI, path selection-GUI and the windowed UI for minimaps and unit selection…. All at a consistent unwavering 60 FPS, with fraps and windows media player running in the background.

OH YES.

Like GSB, this will be a game that really sells itself through videos of gameplay.
Also today I might peak at 9.5kwh of power from my little garden power-station. When that pesky tree gets trimmed, it should climb even higher. Oh yeah.

400% speedup in a pesky transform thing

This code was slow*:

    D3DTLVERTEX* pvert = LocalMem;
    for(int c = 0; c < CopiedIn; c++)
    {
        pvert[c].dvSX -= TransformX;
        pvert[c].dvSY -= TransformY;
        pvert[c].dvSX *= TransformZoom;
        pvert[c].dvSY *= TransformZoom;
    }

This code runs in one quarter of the time:

    D3DTLVERTEX* pvert = LocalMem;
    for(int c = 0; c < CopiedIn; c++)
    {
        pvert->dvSX -= TransformX;
        pvert->dvSY -= TransformY;
        pvert->dvSX *= TransformZoom;
        pvert->dvSY *= TransformZoom;
        pvert++;
    }

Pointers FTW!

I’m doing this sort of stuff now, which isn’t as fast as actually using hardware T&L, but is better than my older, hacky software transforms which happened on individual sprites, rather than at the VB level. Yeah I know… everyone uses world matrices and hardware T&L, I won’t bore you with the reasons I’m not, but there ya go. It works! (GSB uses a per-object world -> screen software transform for each object).

EDIT: These measurements may be a glitch. I’ve run and re-run, and re-run the profiler on both versions and now cannot get as big a discrepancy (although there is still a speed difference). Getting accurate measurements on a multi-core PC that has a live internet connection and various background services running is hell. Now I know why people like console dev :D

*relatively speaking.

Considering multiple attack path mechanics…

Soo… one of the things about doing a reverse tower-defence mode in my game, is that suddenly you care more about the route your troops take. In tower defence, the fact that enemies may seem to mindlessly go off on a tangent doesn’t matter. If they act dumb then yay! if they act clever then yikes! but it’s never frustrating.

As attacker, things change. if a left turn goes to certain death, you expect your units to take the right turn. But is it that simple? Maybe left is lethal to infantry, but right lethal to tanks. Maybe you want to send the infantry to their deaths as a decoy etc. Consider the following map:

In terms of general design and gameplay, I love this. it makes for huge flexibility, unpredictability, and variety. As a player, I can find it frustrating when attacking because the troops may take a route I don’t want them to take. I’ve been mulling over various GUI ideas for issuing orders. None are perfect, and in any case, I’m keen to have GSB-style hands-off play for challenges, which means too many mid-battle controls are going to be a pain.

I can’t yet decide whether it really is frustrating as a player if the routes are chosen by each unit, or if that’s just me as designer panicking. The instinct is to add all sorts of options or UI controls, but I don’t want this game to be complex to play. Hmmmm…..

On a lighter note.

Programming RTS Unit selection outlines

Programming RTS Unit selection outlines is a pain. I had an amazing GUI mocked up by an artist, and most of it is now in Gratuitous Tank Battles, but today’s todo list included unit selection outlines. He had mocked up this:

And now I want to batter him with a baseball bat.

(I always tell artists to do the best stuff they can possibly imagine, and let me worry about how I’ll make it work. Reach for the stars etc…)

You might think it’s easy. Just draw the image bigger first, with a flat shaded effect (I use render states, but YMMV), and then draw the unit on top. WRONG!

Firstly, that means your UI doesn’t shine through smoke or other effects layered on top, which isn’t as cool. Secondly. it means the units shadows are cast onto its own selection UI (yuck) thirdly, it just plain doesn’t work.  It works with squares or circles or other basic shapes, but take a complex image, scale it up, then draw the smaller image inside it. See what I mean?

What I really need is some way of doing what photoshop calls the ‘stroke’ effect, where the outline of an image is expanded. Not expanded directly from the image center, but expanded in all directions.

One solution mentioned online is to draw the flat-shaded bit (enlarged selection) 4 times, moving it up down left and right by 1 pixel each time. That’s great if you want a 1 pixel outline, but 1 pixel sucks, and beyond that, you will get corner issues, plus… 4x rendering potentially every unit in your army every frame is not nice.

Another solution would be to have extra versions of each sprite, already-scaled up in photoshop, and render them for the enlarged versions instead. This has issues where the image already touches the sprite corners, and in any case, that means that the selection outline is a fixed percentage of the unit size, rather than a uniform 4 or 8 pixels, which would look tons sweeter.

So… how did I fix it?

I haven’t yet… It’s driving me bonkers :( I am considering an offscreen render target that blurs a matted sprite, but that wouldn’t be crisp, which I think would look better. I wonder how they did those outlines in age of empires 2?

Note, almost all discussions online about this refer to 3d meshes. I use 2d sprites with alpha channels. Totally different :(

 

edit: this is what I have so far, quite like it, may compromise on it…

Drama doesn’t always mean guns

I’ve just re-watched the film ‘glengarry glenross’. For the unitiated, it’s a ‘feel-bad’ movie that is primarily a lot of legendery actors playing distressed real-estate scam artists shouting abuse at each other. I thought it was good. Anyway…

It got me thinking about a recent discussion following the news about a new star trek shootemup style game, where people (rightfully imho) despaired that even with a star trek game, it’s another game where you shoot stuff.
Now shooting stuff is fun, and it makes for great games. I’m making a game about shooting and blowing stuff up right now (but I’m also involved in a non-shooty game too…), but there is definitely more to life.

People say that drama requires conflict, and that’s fine, but glengarry glenross reminds me that conflict doesn’t have to be rocket launcher vs tank. It can be al pacino vs kevin spacey in an office. I know it’s MUCH harder to code believable, interactable NPC personalities in a familiar situation like an office, than it is to code convincing guys shooting at you, but hey, it’s 2011 shouldn’t we be trying this?

There is a big market out there (I suggest…) for games that involve conflict and drama, that do not involve guns. I’m sure a lot of these ideas suck, but one might work… why can’t we have a game where you are:

A hostage negotiator
A marriage counsellor
A businessman that performs hostile takeovers
A trade union leader
A schoolteacher
The leader of a political pressure group
An investigative journalist
A paparazzi photographer

Forget the graphics, forget the physics and the tech. Make a game based around characters and situations that are dramatic but familiar. I’m sure millions tried farmville because they see farms as something familiar, unlike orcs, or lightsabers. If you could do it right, I think you could make a game out of any of those concepts. It’s tough as hell making a game on a topic that isn’t normally used in games, there is nobody to copy. Sometimes, that turns out to be a great idea.