So wow it’s been a little bit. I have had a crazy 2011. Started working out quite a bit to shed some (a lot of) weight. But here I am picking up the game again.
When last I left off I was able to draw a unit on the table and highlight it. Hooray! Well there were a couple of obstacles in my path that I had to refine.
Issue 1 – I didn’t want to highlight each model in a unit, rather when I clicked on the model I wanted to highlight its unit. To accommodate this, I had to calculate the entire unit width and height. I went ahead and added width and height as properties, which I use to draw a rectangle around the entire unit.
This worked out well. However, I realized that there are two other possible formations in my head for a unit: skirmishers and wedges! Skirmishers would require the old way of boxing each model. Wedges are triangles.
I added a new enum and property to the unit to denote what type of formation it was in. This will be used later when I am coding the logic engine behind it. For now, it is just used to draw the appropriate bounding box outlines when I select.
Hooray I can select multiple units now and have it highlight correctly. This leads to:
Issue 2 – The above worked great when I was in my default zoom. Try to zoom in and out though and click on a unit and I was having all kinds of problems. Clicking a unit didn’t do anything, and clicking the area around a unit would select them. The only real reliable way I had of selecting units was to use my grouping box and sweep it across the screen. This wouldn’t do.
The Problem? Math lol. I was correctly translating my world coordinates, so in normal zoom a point that was, say, at 100,100 was being set at 50,50 when zoomed out. HOWEVER… I forgot to do that with the textures. So the textures, while sizing correctly on screen, were being treated as if they were still 32×32 pixels. This meant the software thought that the blank space I was clicking on was actually inhabited by a model. Or when I clicked on a model, it thought that was open space. Ugh. Problem was quick enough to fix. The end result was that I can zoom in and out and select units and all is well with the world.
Next Step? Sound!
So I wanted to start adding some sound effects. I started simple… a little clicking noise I found online. Actually the clicking noise is quite irritating and I plan on going into my own sound studio and producing some effects with Reason 5.0 but for now this works. I imported the wav file into my project and went about creating a new object in my util namespace called SoundLibrary. A sound library is simply a collection of SoundEffect objects that hold various wav files that I will use on various screens, where I can pass them to the various objects and have them play them as needed.
I madeSoundLibrary accessible via an indexer that passes a string in, which is the name of the file I want access to.
So it is called like this:
SoundLibrary myLibrary = new SoundLibrary();
…{code to add various soundEffect objects}…
myLibrary[“click”].Play();
Fairly simple.
Now I can click units and it maeks an (annoying) clicking sound. This will change in the future when I pop in a better click.wav but for now it serves its purpose.
What’s on the Horizon?
The next step in my evil plans are to be able to select a unit and then right click on the screen and have the unit transported there.
Step 2 – Incorporate a rotate button which will allow the unit to rotate clockwise or counterclockwise.
Step 3 – Incorporate a new sound that plays when a unit is moved in this manner
Step 4 – Incorporate a way to allow you to move each model in a skirmish unit individually as you would in a real table top game.
Things to Think About
I will need to add a movement limiter based on a unit’s move score so that users can’t just move units across the table if they want. (I will need to enable a debug god mode to allow this)
I will need to start thinking about expanding my playing surface and being able to move across a larger table. Right now the screen is the entire table which is representative of about 10% of an entire table at most.
Some exciting stuff in my coding nirvana. I’m off to put together a Ghost Ark for my necron force. See you soon.