Driven around the bend!

Ok, that’s a pretty severe title, but all will make sense as you read on. 🙂

Firstly I’d like to thank Bil over at http://battledrill.blogspot.co.uk/2015/04/ancient-armies-game-development-blog.html for linking to this site 🙂

The first part of this week was dedicated to bug fixing only. I have a zero tolerance policy toward bugs.

The reason for this approach during the development phase, is that with only one person on the team (me!), there is a very real possibility that I could easily become overwhelmed with having to continuously fix things.

I’m sure you all know those game releases that were so full of bugs that they became practically impossible to maintain. As a consequence these games either never get fixed, or they end up going through a ‘fix’ cycle that ends up introducing new bugs due to the number of existing inherent issues. As a result they end up going through ‘fix’ cycles ad-infinitum!

I don’t want to have one of those games on my conscience – hence my zero tolerance policy.

One of the more interesting bugs I fixed this week is shown below:

Can you see the rendering bug in this screenshot? Compare with the image below and all will become clear!

Can you see the rendering bug in this screenshot? Compare this with the image below and all will be revealed!

The fixed version. The swamp now has a background colour!

The fixed version. The swamp now has a background colour!

What made this bug so interesting is that the map always rendered properly when viewed in the map editor. It was only when viewed in the main game and scenario editors that the issue showed itself. This in itself wasn’t interesting, it was the fact that all three applications were using the same code from the same library!

After the bug fixing phase, I put my mind on to the task of getting my units to be able to turn, or in military parlance to be able to wheel about.

Most wargames cheat when it comes to wheeling units. They always have their units unrealistically turn on their centre points. This is unrealistic, because in real-life such a turning manoeuvre would be almost impossible to carry out!

Instead, Ancient Armies looks at the formation shape and then looks at the direction of the requested turn. It then picks a realistic rotation point that a real-life unit would actually employ.

For example consider to the two screenshots below:

Here a rectangular unit is wheeling around to its left. The blue debug line is the intended direction of travel. The blue arrow shows how the unit will rotate to achieve the new requested direction.

Here a rectangular unit is wheeling around to its left. The blue debug line is the intended direction of travel. The blue arrow shows how the unit will rotate to achieve the new requested direction.

Here the unit is attempting to wheel to its right. Note that the pivot point has changed compared to the previous image when it was wheeling to the left...

Here the unit is attempting to wheel to its right. Note that the pivot point has changed compared to the previous image where it was wheeling to the left…

Here the same unit is being ordered to wheel about, firstly to its left and then to its right. Note that in both cases the pivot point has moved to the opposite corner of the unit – just like it would in real life!

The system also limits the rotation speed based on the unit size. This ensures that the rotation speeds remain realistic.

Some other games I have seen have a fixed rotation speed, which is fine. But if you look at some of their larger units rotating, the chaps at the extreme edges of the formation must be on some kind of motorised transport due to the speed they are travelling at!

When it comes to wheeling units Ancient Armies takes the realistic approach. Putting in the ‘realistic approach’ was not a trivial job. It ended up requiring a lot of work!

For example, the orders system had to be modified so that follow-on orders can take into account previous unit direction changes. In the end I really liked this modification as it gave me the opportunity to refactor that part of the orders system. It is now at the point where it is efficient, simple and elegant!

The other complexity that I have had to overcome with regard to orders are the graphics – or in this specific case the curved arrows that can dynamically resize as one moves the mouse.

The difficulty lies in the fact that all modern graphics cards can only deal with triangles – and only triangles!

This means that everything you see in Ancient Armies is composed of triangles – regardless of its outward appearance. Even the ‘curved’ hills!

In this rare-never-seen-before-screenshot below I switch off the graphics engine’s triangle fills so as to reveal the underlying triangles that make up everything:

Everything in Ancient Armies is dynamically calculated on the fly. Everything rendered in Ancient Armies is also composed purely of triangles only - that includes the text. This makes the task of working out how to draw dynamic shapes a little tricky! Add to that the fact that that all triangles must be drawn in a clockwise direction, then it really adds to the fun! (Click for full-sized version)

Everything in Ancient Armies is dynamically calculated on the fly. Everything rendered in Ancient Armies is also composed purely of triangles only – that includes the text. This makes the task of working out how to draw these dynamic shapes a little tricky! Add to that the fact that that all triangles must be drawn in a clockwise direction, then it really adds to the fun! (Click for full-sized version)

In the above screenshot you can see all of the triangles that make up the curved arrow used for a wheeling unit. All of these triangles have to be calculated by the code on the fly. The curvature for each curve is also based on the size and shape of the unit…

Hopefully the above screenshot will give you an insight into the rather complicated triangular world that I have to inhabit when I work on this game!

Before I go, I will leave you with a video showing the curved arrows in action. Note that the graphics representing a wheeling unit are not yet finished…. 😉

Laters

RobP

Advertisements

2 thoughts on “Driven around the bend!

  1. Fascinating… I love that you are actually rotating your formations on the right or left corner (as appropriate)… I remember maneuvering in formation when I was in the service and marching time on the corner while slowly rotating while the outer ranks performed their wheel movement guiding on us, and they often were moving very fast indeed.. just short of a run on the outside of the wheel or turn.

    Regarding your unit counters… Looks like you might have the frontages to real world scale? But not the depth? Or are the unit footprints supposed to represent reality? How about unit thickness for height?

    • Thanks Bil. I too was in the military, in my case the Royal Navy. You would be surprised at how much drill the Royal Navy does when it comes to formation marching 🙂

      With regard to your other question about unit depths I thought I’d reply in the form of a blog post as a picture paints a thousand words 🙂 Let me know if you have any further questions 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s