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

Anatomy of rendering a game dialog box in a custom engine (GSB2)

So I was tweeting that this took forever:

dialog1

It’s just a dialog box for gratuitous space battles 2., why did it take more than twenty minutes to put together? Now… I’ve seen unity, I know it has all these plug-ins that do stuff like this, and that it’s all very user-friendly etc blah blah. But I’m old school. I’m rocking my own custom-written engine, including all the GUI. That gives me huge advantages (mostly speed) and also some disadvantages. The best advantage is there isn’t anything I can’t make the code do.

The pain with this dialog box came in three flavours.

Flavour one was those circular clock-like indicators. In theory, this is really easy, you can just generate a tri-strip of a lot of polygons and draw a curve thats smooth and crisp as you like, as long as you can spare the vertexs. I’m not drawing many, so it’s not an issue. The problem is, when you do that, you get a too-blocky, too un-aliased clunky mess that just doesn’t look ‘right’ when surrounded by lovely aliased everything. I’m not drawing 3D models, so my game has a  nice smooth look to it, and it jarred badly. So I have a sprite of that curve, and I draw a subset of it using a tri-strip arc. It’s a bit fiddly, ant took a while to get right.

Flavour two was the outline of the right-hand part of the window. It’s a bit complex, as it goes in and out and then around the close button and then loops around those circles, and it has to be really slick too, and ironically in this case it looks better drawn as a crisp 1 pixel line, so there is actual hand-crafted code in there to work out all those positions and curve ncie arcs and lines around them.

Flavour three was speed. I like everything in my game to render fast, including GUI. No point in having a fast engine where 95% of the frame is spent drawing a dialog box. That means ensuring that ouline on the dialog is a single draw call with no fuss, that all those tiny animated bits of fluff in the dialog corners and outside the edges are drawn efficiently, that the calculations on that arc outline are as fast as possible, and that the dialog in general; doesn’t use many draw calls.

It’s all horribly, laughably slow really. I probably have a ‘spare render target’ knocking about that I could use to blap this whole dialog to (BTW they resize dependent on the ship, which adds to the complexity), and then only update it when it changed, otherwise just blapping it as a single quad. In practice, the windows various elements update quite a bit.. but I’m sure I could speed up the module icon rendering with runtime aliasing onto spare render targets. I love all this stuff.

But even I know when I’m getting obsessed and need to move on!

Gratuitous Space Battles 2 is officially announced…now

I know blog reader regulars know this already but… I’m working on this:

GSB2-Black500w
Oh yes indeed.

I guess not many people will be surprised, the original game sold very well, was very popular and seemed to have an endless lifespan thanks in no small part to an excellent community of modders. The reason for doing a sequel isn’t financial though (I’d be doing Democracy 4 if it was), but driven more by a desire to do the job properly.

Gratuitous Space Battles was the first time I ever tried to do a game that looked impressive. I mean it. Kudos and Democracy are not designed to be a feast for the eye, they are interesting simulations covering topics not covered before. Those games are about choices and mechanics. The GUI was there because it had to be. Nobody looks at those ‘happiness’ sliders in kudos or those bar charts in Democracy and says ‘I gotta get me some of that!’.

menu

I love space battles. I love em to bits. I could sit and watch them on and endless loop. There is so much to them, the feeling of scale, the sound effects, the particles, the cool lasers, the amazing nebula backdrops and the vast vast fleets of ships doing amazing acrobatics. As a kid I grew up watching the original star wars movies and playing Elite. Space Battles are in my blood and I love them. Game-wise, I *want* to liked Eve online, but I’m sick of being ganked by some teenage boy and his pals for their amusement. I don’t want the lowliest of the low mining ships that gets one-shot killed. I want a huge fuck-off spacefleet. I want to be ackbar.

battle

GSB2 is a continuation of my fantasy of making this come to life. There are various questions answered on the placeholder website here, but let me summarize. GSB2 will be bigger, bolder, better and have more cool effects than you can shake a laser gun at. It will have a truly gratuitous user-interface. it will lovingly embrace the possibilities of twin 2560 res monitors. It will have a super-cool feature I haven’t announced yet. It will be a PC-first game, pure and simple, and it will be in your hands either late 2014 or early 2015. And you can play it in London at the Eurogamer Expo in September. If you are press and looking for presskit logos etc, clicky here.

Videos to come in due course. You are going to *really* like the videos.

Posted in gsb2 Tagged

The programmer constraint

Positech Games suffers from the programmer constraint. Everything that gets made directly by positech goes through the funnel of coding by me, and it’s becoming difficult to keep that up. GSB 2 is a BIG BIG game. It introduces a lot of new features to the game, and it has a much much more complex engine (a multi-threaded one). It will also have higher production values, more music and art and so on, than it’s predecessor. This is fine, as I have the budget to match my ambitions, and no real time constraint (although I’ll have to have a ‘playable’ version for Eurogamer in London, this September. The only thing that holds the game back now is me.

I’m the only programmer, and that is a pain. GSB2 uses my own custom engine, and no middle ware other than a sound library. There is a LOT of code, and although I do none of the art, the constraint of me being totally the only coder slows down the games production, and possibly limits its scope. I can see various mitigation strategies.

Mitigation Strategy #1

Delay the game. Just deal with the fact that it will take another year, and keep plugging away. This is the easiest option, although one I don’t like. I dislike 2 or 3 year projects. I already have plans to show the game in September, I can’t wait years to release after that. Plus the memory (and player-base) of GSB will degrade more the longer I leave it. Plus also I won’t earn any money until I start selling it!

Mitigation Strategy #2

Scale down the ambition. The engine runs very fast already, it really does not need to be optimized that much more. The GUI can be functional but not flashy.  I really don’t need to go bananas with features like steam leaderboards or online messaging etc. That’s stuff I can leave out of the game. I dislike this strategy too. This is a sequel, it should be the better interpretation of the idea, with better everything, and all cool features intact. I’d be disappointed otherwise.

Mitigation Strategy #3

Hire a coder. This would be ideal but vastly problematic. Experience with Unity or Unreal or the Source engine will not help you with my engine. it’s all my work, and never written to be understood by anyone else. Plus how can I be sure their work is good without checking it and testing it, which might take more time than me just doing it? I  am not good at code collaboration, so this might keep me awake at night. What if they code some bugs I then have to fix? Nightmare… Plus I’d be VERY picky. How will I find a very experienced (no time to teach) coder that is available, reliable, affordable and motivated enough to work alongside me between now and the project end. This is unlikely.

Mitigation strategy #4/

Offload everything else. I already have taken steps towards this. My Linux & Mac ports are done by other people, some of the PR stuff is outsourced, as is making trailers. All the art and music is outsourced, should I hire a sound designer to pick sounds too? what else takes time? QA? Should I hire some QA company to do playthroughs? Could I maybe hire a designer to do some balancing? A writer to do some writing? Even though i am never really happy with it (because its’ hard to edit) should I take the plunge again and get the website designed and implemented entirely without me?

This is my favorite strategy. I can probably do a bit more of this, offloading all ‘non-core’ code stuff, and literally everything else. it does mean a pure-code lfie for me, which can be a bit maddening at times. I still have the biz strategy and advertising task in my court though :D

Insanely big GSB2 screenshot

I’m ahead of my self-imposed schedule, so I spent a morning getting multi-monitor support working right for gratuitous space battles 2, stretched across 2 2560 res monitors. I’m quite stunned at how little that res affects the framerate, I took this at 56 FPS. click to enlarge, but you might need multiple big monitors :D

huge

 

Posted in gsb2 Tagged

GSB2 Multithreading a single frame (so far)

Here is a big battle on GSB2 running at 1920 1200 res, on a GTX 670, quad core windows 7 PC. This was taken using the visual C++ concurrency visualizer. 3732 is the main game thread. Green is busy, red is idle, light blue is sleeping (end of frame, waiting for flip). Click to enlarge.

multi

1284 seems to be the thread where directx or the nvidia driver does it’s stuff (not sure which).

7596 2692 and 2788 are my additional threads of GSB2 doing processing. Each of those colored bubbles represents one or more tasks that a thread has grabbed and is working through. The big red stretches are obviously gaps I could potentially fill as I find ways to break apart dependencies of tasks and push more of the main thread into the other cores. It’s obviously already been worthwhile, as I reckon I’m currently doubling the framerate (just about) thanks to multithreading. Almost all the grey blobs are transformation of particles within particle emitters, packed into arrays. These are too numerous and cause too much thread-scheduling right now so I might make those arrays bigger, or even dynamic sized.