Yet more bits & pieces..

More little bits & pieces done today..

Firstly, I’ve implemented proper black borders around the screen if they are required. This is to erase the overdraw caused by the cloud drawing, which can move into the border area due to the way they are animated. So, in a widescreen display black borders are drawn to the left and right, and if in a portrait display (or a screen mode where the ratio is not 4:3) then borders are drawn top and bottom. I tested it in a variety of windowed sizes and it works fine for me, and it should hopefully make the game playable for more people with widescreen monitors. Smaller screensizes do make the small font look much worse though!

I’ve also implemented some code which at the start of a spell selection phase, goes through a human wizards spells and checks each one to see if it is castable or not (any space, or targets available). If not then it is shown with a red border and moving over it with the mouse shows a Can’t Cast message in red at the bottom. It is of course not selectable. This helps the player at a glance to not look at spells which can’t be cast. As you can tell I’m hugely in favour of these kind of UI designs which reduce time and save the player unnecessary work!

Following on from that, the game will now also show a green border (for one turn only) around new bonus spells found from magic woods. I did something similar in Chaos Funk and this does help show the new spell..

I’ve implemented a proper spell casting check for the AI wizards too, so now no spell that can’t be cast should be selected. This was much easier than would have been possible in Chaos Funk due to the design of Chaos Groove. Something I’m going to touch on in a later post.

Oh, I also added a AI check to make pieces that can be ‘ridden’ be cast closest to the wizard. This is to stop spells like Magic Castles being cast close to the enemy like shadow woods or walls would be. Using the ‘rideable’ stat lets me avoid hard-coding things like this for specific spells, something I’m trying to avoid at all costs.

Finally, I’ve fixed a few bugs with the AI, and made the vertical spacing between the text at the bottom shorter, so it now lines up with the brief spell description as drawn using PTK’s multiline text function.

There is still some errors when highlighting the current wizards creatures. This is made more difficult because I’m trying to set the highlights intelligently in case working out the path-finding each frame kills the framerate on slower PC’s. It shouldn’t do really, but I’m trying to make the game work well on many different kind of PC’s.

I’ve still get a few bits to do before being able to do a new demo. I’ll try to do one soon, but I’m not going to promise a date!

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.. 🙂

Behind the scenes progress

I’ve done some more work in the background of the game today. I’ve improved the way the descriptions for the non-creature spells are presented. Now they can use upto 3 lines of text with word-wrap, which makes the display look much better.

The Line of Sight routine has been redone to be much improved, and so far it seems to be working ok and as expected.

I’ve added two new spells, Subversion and Raise Dead. These were easy to add, but did involve adding some more new flags. For example Raise Dead actually moves a piece from the BODY layer to the PIECE layer in the game, then changes the wizard owner (as subversion does), and then turns on the Undead status flag and the Can Attack Undead status flag. So as you can see, it would be possible to make a spell that has a higher chance of working, but which restores any dead body to it’s original owner and doesn’t make the piece undead.

Finally I’ve started work on making the AI use the walls, castles and tree spells and deal with them on the board. First attempts were a bit comical, as the AI turned into a pack of demented lumberjacks and started trying to kill every tree. A few more checks for the defence, attack and movement values being 0 have helped that quite a bit, but there is still no flag to show the AI that magic woods can be ‘ridden’ by anyone. Once that is in it will work much better and let the human wizards go in enemy magic woods too..

Progress is very fast so far, but my motivation and free-time won’t last for ever, which is one reason I’m trying to get as much done now.

Castles & Trees


Here you can see Castles & Trees now in the game (although the AI doesn’t use them yet..) I know the magic wood trees are a bit flat, but at least they are in there for now.

I had to expand the engine a bit to support trees and castles.. A piece can now have a chance between 0 and 100 of disappearing each turn prior to movement. Associated with these are flags for only disappearing if a creature is riding on it (i.e. a wizard in a magic wood tree), an effect name say that we can make castles explode, but magic wood trees just disappear. Also an associated number of bonus spells value for if a piece disappears so we can implement magic woods.



# Group details are used to stop trees being cast adjacent to each other.

(The config files used by PTK don’t handle spaces very well, hence the use of underscore characters..)

I also had to alter the movement code to do a check to stop shadow wood trees moving over bodies if they kill a creature. Changes have been made as well as deal with defences of 0 (invulnerable) and attacks of 0 (can’t attack).

To make it so that trees are not able to be cast next to each other I’ve implemented a group name that each piece can have, as well as a flag to say if a piece can be positioned adjacent to someone in the same group. This lets me call both Magic Woods and Shadow Woods as being part of the Tree group and not being able to be next to each other. This was a bit more coding, and I have to pass the group name as text string around a few functions. However, this lets us have other uses for groups, say to let a mutation spell know to only pick from creatures in one group.. and it also stops us hard-coding something just for trees. A silly example is that we might want new spells of a Cat and a Dog, but not want them to be next to each other..

Well, all this was a bit of work and I still need to make the AI use these spells, and I also need to tidy up some parts of the code which are getting a bit difficult to follow. I don’t think I’ll get much more done today, but enjoy the pic and progress report! 🙂

Fixed a few bugs

I’ve fixed a bug where the check to show if a creature (or wizard) was riding on top of another one was wrong in the status panel at the bottom. This sometimes resulted in “()” appearing after a creature’s name.

Fixed a couple of bugs related to riding creatures and dismounting from them.

Fixed a few visual bugs with highlighting friendly creatures and creatures that could be selected.

Posted in Bugs. 2 Comments »

Ohh.. Look at that!

First of all I think I’m going to use quarter sized images (640 x 480) instead of using the full sized screenshots and letting WordPress make a teeny tiny little thumbnail..Screenshot 10

So, as you can see from this screenshot you will see I’ve added the Wall spell. I have yet to make the AI players use this, but you can cast upto 4 blocks as in the original. In the above screenshot there have been 2 wall spells been cast in case you were wondering where the extra blocks came from!

I’ve had to expand the engine to provide support for spell icons, (in addition to using creature sprites as icons), as well as adding extra features such as multiple casts to be used with walls and shadow woods. This also means that you could now make a spell which lets you cast 2 dire wolves, or 3 orcs.. 🙂

I’ve also added support for text descriptions for the non-creature spells, and rearranged the user interface at the bottom to make better use of colour to more clearly show each creatures statistics.

Law-1, Law-2, Chaos-1 & Chaos-2 are also now implemented, but since they are the most useless spells in the game, that’s not so great! 😉

Buggy, bug, bugs!

Today has been one of those strange days that just leave you scratching your head!

I’ve had two hard crashes today while working on Chaos Groove. Both times neither Alt-tabbing, pressing ‘Control, Alt, & Delete’, or physically pressing the power button on my machine worked. I’ve had to manually unplug the PC and then replug in just to escape from the frozen game. The strange thing is I think that the error is not just due to my mistake, but due to the MSDN debugger. The second error when I reran in a windowed mode (to try to be able to get back to the OS), showed a simple undefined variable being added to, while not being used in an array or anything else like that. This time the debugger caught it, whereas just one minute earlier in fullscreen it hard crashed the PC when running in Debug mode.

About halfway through the day today I got a very strange thing happen with my particle effects. They were being drawn at the wrong angles after a creature attack effect, and even the spell beam effect was wrong. I couldn’t understand it and tried tracking it down, but it seemed that PTK’s blit was at fault because I hadn’t changed anything to do with the code in the particle side of the game, yet suddenly it was using the angle values passed to the blits very wrongly indeed. Despite double-checking the actual values passed (which were correct and hadn’t changed), the angle values were being treated as twice as large as they were. I.e. if I passed 0, it was correct, but passing 45 was treated as 90 degrees and passing 90 was being drawn as a graphics rotated to 180 degrees. A simple divide by 2 fixed this error.. But this is not an answer and makes the whole code feel far too fragile!

Finally I noticed something was a bit wrong in the config file reading for the new display code. It seemed that due to a comment error in the display.ini file, PTK might have been asked to open a fullsized 1280 x 1024 window instead of a fullscreen mode. I certainly never noticed any window gfx previously, but it seems for some unknown reason this completely screwed up PTK’s angle code. I haven’t got a clue why.. It’s now all working perfectly again.

It’s just been one of those days where I suspect I’ve attracted the attention of a malicious gremlin. 😛

Posted in Bugs. 6 Comments »


Thanks for the positive feedback on the first demo release!

Apart from a few teething issues for one person with a laptop, it seems the demo works well. I’m also pleased to see people like the modern interface and graphics, which I think does help the gameplay.

The next demo release will have the display settings stored in an easily modifyable text file, so people can alter this to make the game run according to their machines capabilities and also to suit their own preferences.

Of course, I can’t promise that all feedback suggestions I receive will be implemented, but some of the feedback ideas will no doubt be implemented that will make the game better.


Interface Design

I’ve tried to design the User Interface used in the game with two points in mind: Efficiency and Simplicity.

So, I wanted the interface to be as quick to use as possible without clicking on a lot of buttons, but without being intrusive and getting in the way of the board. This has been carried through into the game, so that you move over a spell icon in the Spell Selection Phase of the game and the places where that spell can be cast are automatically shown on the board. No buttons need to be clicked on or pressed to make this aspect of the interface as quick and as simple as possible.

However, I also don’t want the interface to intrude and get in the way of the board view, so if the mouse is moved off of the spell icons then the highlighting disappears straight away.

This has led to a slight dilemma when trying to show to the player his wizard and current creatures. Moving the mouse over an enemy creature is not a problem as I can just highlight all that wizards creatures in red and it doesn’t really intrude. However if I try to highlight our wizards creatures in a similar way it clashes with the movement highlighting. If I try to make the highlighting appear when the mouse is over a blank square on the board then this is too intrusive and gets in the way. I could add buttons in the bottom right of the interface, but this is also a little awkward.

At the moment I’ve made it so that holding down the right mouse button (as long as no creature is selected) will show the current wizards creatures. This is very handy, but not the best solution. So, I’ll still be thinking of a better way to do this.  🙂