Building Better Bullets

I spent Friday building a stand-alone prototype for a completely new bullet/projectile system. The old method was starting to become pretty unreliable and inaccurate for actual game-play situations, and there was no real way to draw a “Bullet” travelling through the game scene.

Now I’m actually drawing bullets flying along a path and checking for creature collisions along the way. It seems like an obvious way to do things, but when I was creating the old projectiles I was not familiar enough with how the game scenes were going to be processed, so it didn’t seem like this method would actually be possible. Now it’s fully implemented and working nicely.

I’ve also now made it so that bullets do not stop where you click to fire them, they go until they hit a wall or run out of momentum, meaning you’ll have to really think about what you might hit before firing a weapon in a scenario.

Potentially Boring

While making the “Popup” boxes work in a fully implemented way, I recorded ten minutes of my desktop footage just to show a little bit of my workflow. Most will find this kind of thing extremely boring, but some people might like to see how a game actually gets made.

The video basically shows the “Warm Up” bars being displayed when a creature doesn’t have the big popup box open over an object they’re working on. I wanted it to be clear that a creature keeps working on an object even after you close the popup box and go do other things. Once the creature finishes working on the device, a “Cool Down” bar appears over the device (This part was already working prior to recording).

Also, have a photo of my desk.

Performance and Fixes

I’m not too sure exactly how much of a graphical powerhouse I can expect to really pull out of the engine I’ve built, so I’m working out exactly how much I can take advantage of zoom effects while still allowing hundreds of sprites to be on-screen at the same time. I’m now locking the game at 200% zoom all the time now, as I think it looks best that way, and also locking the framerate at 50fps as I seem to be able to consistently pull that in any game scene. Once I get to work on real optimizations, I might be able to jump it back up to 60fps, but at the moment it’s just too unstable at that cap while still using zoom effects.

I finally managed to fix that bug where, after 40mins of inactivity, player characters could no longer move. Turned out their “Decision Cooldown” kept cooling down below zero if they didn’t make a decision. Eventually it would reach “absolute zero” and couldn’t move any-more, to put it in simple terms. Fixed; much better now. The debugging process was a frustratingly late night of continuously re-trying different break-points and spitting debugging text all over the screen.

But enough about boring stuff, here’s the first ever publicly released video of my work so far!

 

Bugs So Far

There’s a few bugs I’ve been noticing from time to time that have been really hard to sort out. For quite a while now, when creatures decide to use pathfinding, any other creature on the field who was already using pathfinding will suddenly forget where he’s going. If two creatures were trying to use get through a maze, they’d keep “stealing” the ability to pathfind from each other and running around at random.

Another issue appears sometimes where if the game is allowed to run for about 20mins straight, the player characters lose the ability to move completely. I have no idea what’s causing this, but it might be related to the pathfinding banks becoming completely unavailable or something to that effect.

Amongst other small functionality improvements, I’m making lots of small but complex map layouts to try out different situations and see if I can nail down these movement bugs. So far I’ve resolved to just give every creature their own pathfinding bank instead of having a shared managed pool of them to use. It means that if I have more than 50 creatures in a map, more memory will be used as the previous pool only allowed 50 pathfinders at a time, but overall I don’t think that’s a big problem. If it solves these bugs, I’ll be happy with it.

A new unrelated feature now is the ability for all creatures to move at speeds independent of each other, so one creature can run while another walks. I also added a new “Running” animation for this.

Progress (Bars)

Still concentrating all my work on the popup boxes, I’ve got them linked into the AI decision-making process now so they are actually opened by creatures instead of the player directly. Creatures decide to “Go Open Popup” and walk over to a trigger to open its popup box. Only player creatures can make this decision, which is caused by clicking on a trigger while a playable creature is selected. Other, non-player creatures can interact with triggers without using the popup boxes.

The popup boxes are now handled inside the AI loop as well, meaning they can actually cause things in the game world to happen. At the moment, opening a trigger’s popup box and clicking anywhere inside the popup window will cause that trigger to fire off all its linked objects.

Eventually there’ll be multiple buttons on the popup windows, each with a progress bar for how long it takes to use that button, and a cool-down for how long you need to wait before using that trigger again. I’ve implemented the graphics for the progress bars upon the popup boxes, but they don’t actually do anything yet.

Pixel Perfect Popups

I’m progressively building a small GUI engine to place inside the popup dialogues that appear in-game. They will eventually be the main way that the player interacts with objects within the campaign, so they need to display text, icons, buttons, and basic animations. They also need to be able to detect clicks with perfect precision.

These things would usually be easy if it weren’t for them being placed on a not-square surface. I spent today getting the click detection working for them, and making the little red “Close” button at the top-right work. I’ve also implemented the text rendering on the face of the popups.

The font looks incredibly ugly.
 But when it appears in game, it looks quite effective. I’m pretty happy with the result so far.

Platforms and Popups

Within 3.5hours of bringing home a refurbished iMac, the current build of the game is up and running on it without error. The game actually runs significantly better under Mac OS X than it does on a far more powerful machine running Windows 7. I can’t imagine the reason for this, but the eventual goal is to be pulling 60fps on any reasonably powerful machine in the long-run anyway.

Work on the in-game interface has ramped up now and I’ve started work on the “Popup” system, where clicking on an entity in the game world will cause a popup dialogue to appear above the device with options for how to interact with that device. At the moment, a series of cubes smoothly rise out of the device and build the popup dialogue in a pleasant smooth manner. There’s no way to actually interact with the dialogue so far, but it would be an interesting experience trying to create a point/click interface on a not-square surface as you can see in the included screenshot (Running on a Mac!)

Creation of Assets

Now that the campaign editor can create real content for the game engine, I have just been churning out graphics and throwing little test campaigns together to see how fast they run and how long they take to load. At the moment loading is slow with what you see here taking about ten seconds to load into the game. I’m not sure how this will improve over time, but it’s good to be able to finally benchmark real content in the engine rather than just hard-coded test data.

I’m finally getting a chance to throw huge arrays of sprites into the game and seeing it render them at respectable speed.