Testing & Fixing


Here is a screenshot showing some of the new additions. Notice the massive range of the Lightning spell for testing purposes, and the way that pieces on the board are obscuring the line of sight. The line of sight routine is rather generous, since from my own experience it’s more frustrating not being able to cast a spell that you think you should than the other way around..

I noticed earlier today that for some reason whenever I moved over some spells like Raise Dead and Lightning I got a massive frame drop from 60fps to around 20-38fps. At first I thought this was perhaps an error in the line of sight code or the highlighting code, but that checked out fine. After more testing I found that drawing the spell description was responsible for the slowdown..

Switching to a single line text system removed the frame drop, so I thought that it was my home made word wrap code that was to blame. Well, it wasn’t too efficient, so I rewrote it to work properly and more efficiently, but saw no difference! After more testing I found that the getstringwidth function in PTK was killing the framerate. Well, I remembered reading something about a speedup in the truetype functions in PTK and checked the website. It turned out I didn’t have the latest version of PTK downloaded as I had thought and instead had an older version where the truetype text was about 160 times slower (according to the history). So, one swift update later and now it ran great at 60fps again!

The new version also provided a new multiline function though. It doesn’t let me adjust the vertical spacing to get a nice lineup between the three lines of the description and the info on the lines on the right. That’s the downside, but the good part is that it does let me have extra spacing between words to get perfectly alligned text at each end. This does look better, so I’m using this function instead for now.

I also had another silly bug in there where the highlight square in position 0, 0 of the board was always being removed for some spells. I tracked that one down to a missing alive check when finding if a wizard was in a square. As a result wizards that were not alive had a position of 0, 0 and were triggering the ‘can’t cast on wizards’ code which removed highlights from them (including 0,0!).. Doh! Now, it’s fixed.

So, two little things which took a few hours to trace.. 🙂

Tightening the experience!

I’ve been working on a few different things today to improve the game:

  • Made the spellcast effect shorter in duration, because it seemed to be going on a bit too long, especially when casting trees.
  • Stopped the yellow highlight cursor effect being drawn when the AI has it’s turn. This makes things look better when land based creatures with a few movement points are moving. Previously the yellow highlight square would be placed at the empty destination square, which could look a little odd.
  • Added a dull grey highlight for spells which only affect other pieces (subversion, magic attacks, etc..) This is to help show the spell’s range, but is only applied to empty squares.
  • Made the range of a spell be displayed in the spell’s description.
  • When a wizard dies, his or her pieces now go through an exploding particle animation as well as disappearing.
  • Added a 3rd highlighted cursor style (4 corner brackets, slightly thicker than the dotted border line cursor). This is now used to show owners of a piece, and so if you move over an enemy wizards creatures his pieces will be highlighted in red. Moving over your pieces will highlight them in green (or blue if they have moved), as well as showing the squares that creature can move to, attack or mount. Unlike previously where I tried using the dotted line highlight, the different designs help distinguish things. So, dotted border squares are where you can move to or cast onto. Thick solid border squares are where you can attack or ride (mount). Finally the new corner square border is to show a piece’s owner. Slightly more complicated, but I think it works well when you play with it for a while and is less confusing and more intuitive than other approaches.
  • Pressing the right mouse button over a empty square will now highlight all pieces on the board by their respective owners colour. This is a very handy way to see who owns which pieces at a glance.
  • Added support for magic missile spells with the ability to change the missile gfx (the default one is the white spell beam gfx), the casting effect (the default is the spellcasting effect), the amount of the effect, and also I’ve added an attack value to use against the creature. With this in place, I’ve implemented Magic Bolt and Lightning and these new options let us also do other spell combinations if desired.

All these changes help to improve the game and make it more easy to play too.. 🙂