Categories
Projects

BattleGrid Update – May

From now until the end of development, I’m going to do a monthly wrap-up of what’s been done with BattleGrid. Hopefully there won’t be too many of these before BattleGrid is finished.

How’d May start?
At the beginning of May, I still had two major problems that were holding back development. First, the number of draw calls was far too high for the simplicity of my game, and without lowering the draw calls, BattleGrid was unlikely to run well on the iPad. Second, the AI was eating up far too much CPU time, mostly because each turret had its own AI all trying to run at the same time, which was hurting framerate.

What got done?
An epiphany on the draw call issue ended up solving the problem. Even if the problem isn’t totally solved (I have a feeling it will pop back up later), I know how to tackle it to improve the draw call count. A similar epiphany struck me related to the AI, which has eliminated problems with too many AIs trying to run at once.

In addition, I’ve added an extra animation to one of the turrets, which looks great and adds some life to the game. I’m planning on updating the remaining turrets with similar animations. I also added a new effect when shields are hit, and I added or improved several sound effects.

What’s left?
AI Rewrite and Updates
I want to rewrite my AI to use a finite state machine, custom code, or a new behavior tree system. Currently, the behavior trees are created with Behave, which is free and works great, but it requires a 3-second logo to appear when the game starts. BattleGrid has a long enough load time as it is, so I want to trim out everything I can. The AI also needs some general tuning to run faster and make sure I don’t have any memory leaks or excessive garbage collection.

Effects
While I love the style of the game and think it’s gorgeous when it runs at 60FPS, it’s still a bit bland. It’s lacking anything that makes you go “Wow” or even “Neat.” I think what’s needed here are more of the effects that make the game feel more alive, and I’ve begun adding those.

Defense Mode and Editor
Defense mode and the editor need testing and bug fixing. I play skirmish and challenge maps a lot, but defense doesn’t get as much love. The editor, likewise, hasn’t seen any work or bug fixing in a while. There are also several bits of the game that need finishing, like the victory screen.

Map Sharing
I need to create a site for BattleGrid where I can support map submission, viewing, and downloads. I plan on letting players upload, rate, and download maps from the server. None of this has been set up yet.

Music
I’m not a composer, so this is going to be incredibly difficult for me, even though I know the style I want.

Goals for June
I’ve been playing a lot of Diablo lately, so I’ve cut back on how much I expect to get done. For June, I just want to get those extra effects in, and maybe some bug fixes for the editor and defense mode. I’m also planning on looking into what it would take to rewrite my AI as a finite state machine. I like behavior trees better, but my AI is so simple a state machine may work just as well.

Categories
Projects

BattleGrid Update – An Epiphany

So I finally had that epiphany I was hoping for. I should have expected it to come to me as soon as I decided to quit working on it…

I was reading over my last post (in which I decided to quit working on draw calls) and I realized that the majority of the vertices in that vertex buffer are used up by my grid tiles. Although each individual tile only has 4 vertices, the map as a whole uses up a large chunk of the 4000-vertex buffer. My problem was that I was trying to get everything into a single batch – it’s simply not going to happen because there’s too many vertices to batch. So I decided to try something slightly different. Instead of trying to batch everything together, I’ll batch all the tiles together, and all the structures separately. And today, after about 3 minutes of work setting up a new material for just the tiles, I’m down to around 20 draw calls. Well within the iOS “limit” with room to spare. So I’m happy and I can still move on to doing more interesting things.

Categories
Projects

BattleGrid Update – Screw Draw Calls

Trying to get my draw calls down is extremely frustrating. I’m slowly learning what I’m doing that’s causing the batching to break, but I’m also finding out that some of what I want to see (draw call wise) simply isn’t going to happen.

I just found out that the vertex buffer for draw calls is around 4000 vertices (at least as of 2009). For a 30×30 map, my grid alone is 3600 vertices (900 grid tiles * 4 vertices per tile). For a 40×40 map (my largest maps), that comes out to 6400 vertices – already too many to batch. So, trying to get my terrain and structures to batch together is futile anyway. On the other hand, it seems like I should still be able to get down to just a few draw calls. Even if I max out that vertex buffer each time, I should still only be making about 4-5 draw calls, not the 86 I’m seeing. Those 80 extra draw calls are really causing me grief, and Unity can’t be so stupid about ordering things that it can’t properly organize the batches…

So for the time being, I’m going to forget about draw calls and get back to the fun stuff – AI and bug fixing. I’m going to do some optimization to the AI to get it running smoother, then fix the few things that are still slowing things down (like rendering map previews). Maybe I’ll also take a stab at the map submission website. Anything to get my mind off those damned draw calls.

Categories
Projects

BattleGrid Update – Graphics

Since I’m kind of stuck progress-wise until I figure out what to do about the draw calls in my game, I decided I’d do a post on some of the updated graphics in BattleGrid. Looking over the images I’ve posted in some previous posts, I realized that things have changed a lot since I posted those images.

New Tile Graphics
Tiles have gotten two big updates – first, I reduced the number of planes used for a single tile from three (base, owner highlight, and an extra highlight) to one, which cuts the number of polygons on a single map by two-thirds. Always a good thing.

Second, I found a really cool (and more importantly, free) circuit board drawing that I put on the tiles. I love the way it looks, and it makes the grid a little less barren.

The new map tile, with a circuit board texture.
The new circuit board tile.

The “contested” tiles also got a graphics update. They’re now “cracked” tiles. I like them, but they’re likely to see some updates before the final version:

The new contested tile.
The new contested tile, with a “cracked” look.

They look best on defense maps where it looks like the gateways have “infested” the map. Speaking of which…

New Gateway Texture
The original gateway texture hasn’t been shown before, but it was using a noise-generation function to animate the portal. It looked neat, but killed performance, so I scrapped it. I use a flat texture and a particle system now, which looks pretty good:

Gateway
The gateway, used by waves of enemies to invade the grid.

If the gateway looks a bit like the obsidian portals to the Nether from Minecraft, that’s good because it’s exactly what I intended. If they don’t… Well, that works, too.

New Buttons & Windows/Dialogs
I’ve said before I hate the gradient backgrounds on most of my buttons. The idea I’ve been thinking about for a while now is using scan line backgrounds, sort of like a holographic display. I finally created some, and I’ve updated practically the entire UI to use them.

The new “holographic” buttons come in two styles – the main menu buttons:

New play button
A good button for games to have.

And the window/dialog style:

Close button
Used for… closing things.

The dialogs themselves are supposed to look a bit like a holographic display. They’re lacking in depth, though, but with my new UI framework, I should be able to eventually do something about that.

Pause menu
Kind of boxy.

The new UI uses a package called “NGUI”, which is actually pretty cool. I’ll write a separate post about NGUI soon, since it has totally changed how I think about the UI.

New Factory Model
The last time I mentioned factories, I said the factory was likely to see another model update, and they have. The new model looks a lot like the original:

The newer new factory.
The new(er) factory

However, this one is animated, so when it’s building the “wings” fold down and spin:

The newer new factory, building a tank.
The new factory looks better when it’s moving.

It looks pretty cool in action. I also added a “platform” under the factory to make it a bit easier to tell that the factory covers 9 tiles. The platform isn’t in these images because I took them before I added it. Maybe next time.

Categories
Projects

BattleGrid Update

I’ve scaled back my work on BattleGrid a bit. Through February and March, I was working on BattleGrid like it was a second job, and I could definitely feel some pressure building. I was making a big push to get something ready for PAX, and even though I missed that target, I’m happy with the work I got done. It’s just not a sustainable pace.

That said, I’ve been working on the problem I mentioned in my last BattleGrid post – draw calls. I’ve been trying to get batching working properly, and to that end I’ve got my texture atlases set up and all my meshes updated to use the atlas. In theory, a scene in my game should be using less than 10 draw calls: 1 neutral material (for the neutral player and projectiles), 4 colored materials (1 for each player), 2 for the UI (foreground and background), and a few for particle effects. Instead, I get 300 – 400 draw calls. For those of you keeping count, that’s 3x more than before creating the texture atlas and updating all my meshes. It’s the exact opposite of what I expected.

I know the atlas is supposed to work, so there’s obviously something else I’m doing wrong, I just don’t know what yet. Maybe I’ll have an epiphany and realize I’m doing something stupid, or maybe I’ll spin my wheels for a month or two and get very little done. I’m hoping for the epiphany.