Saturday, August 28, 2004

Saturday 28th

A welcome return to the land of code today saw a few major changes (albeit behind the scenes). My first task was to get the Grid display functions finally sorted out. The user can basically display one of two different grids: the first grid is a basic affair, which can be changed to any size; the second grid is a Brush grid, and changes size according to the currently active Brush.

After a bit of head-scratching, I managed to merge the two grid display routines (modular programming is much cleaner and efficient), so the user can now view either grid, and choose whether or not the grid scrolls with the map or stays "locked" to the screen. I also added a Menu function which allows the user to change the grid size via a pop-up window, though this needs further tweaking.

I was all set to work on my snap-to-grid routines, before I had a flash of inspiration. Currently, the Brush is handled from the top-left, which is all well and good but limits where the user can actually place the Brush. The only graceful solution is to allow the user to change the Brush's handle point (if I recall, Deluxe Paint had a similar facility).

With this in mind, a further chunk of time was spent implementing a toggle so that the user can choose between top-left or bottom-right - I also had to tweak the display, plot, and clipping routines accordingly, but the end result was worth it (I just wish I'd thought of it at the beginning while the routine was still fresh in my mind!).

I also took the liberty of removing a couple of checks from the brush clipping routines; I discovered that Blitz automatically clips any images or geometry drawn to the screen, so my checks were basically redundant and unnecessary (the processing time is negligible but if the code is redundant, it shouldn't be there). The only checks I now perform are to ensure that the plotted Brush doesn't spill over the array boundaries and corrupt other areas of memory.

I did quite a bit of research into Types and Arrays, as I'm pretty sure some of the functionality I want to include will rely on Types of some form, particularly if I want to include multiple Brushes (I'm not quite sure if it's possible to have arrays of arrays).

In preparation for this, I changed my brush variables to array pointers, which entailed tweaking a couple of routines. It's always a bit scary making big "search & replace" changes to code, but after a couple of compile errors the thing fired up without a hitch. Phew!

I rounded off the night's session by implementing the Brush flipping - the user can now hit X or Y to flip the Brush along the respective axes, and I also threw in an extra line of code to flip the Brush through 180 degrees. I did attempt the Rotate Brush function, but with the time approaching 7am my brain wasn't up to much. Maybe tomorrow, as the Littlest Hobo once sang.