Monday, January 3, 2005

Monday 3rd

While I was putting together the screenshot for yesterday's entry, I took the liberty of increasing the tile size to 64x64 (as opposed to 32x32 as it was previously), and doubling the size of Monitor and its bullets. Combined with the new HUD and screen resolution, I was suitably enthused, and today I decided to plough ahead and write the map display and scrolling routines.

As is often the case, I tend to look at tutorials and other people's code to see how they approach the task in hand (very rarely does cutting & pasting someone else's code prove useful - after all, if you've no idea how it works, you can't fix it when it doesn't work or make amendments if you want to expand its capabilities).

After a little light reading, I started off by copying across the map display variables and routines from my Map Editor (technically speaking I should have made the original code modular enough to use seamlessly across a number of applications, but that's a valuable lesson for future projects). With very little effort I had the map up on screen in no time.

After this began the tricky task of implementing a "fine scroll" routine to compliment the "coarse scroll" routine already in place (the latter scrolls the map an entire tile at a time; the former allows the map to be scrolled pixel by pixel).

This proved easier than expected, so the bulk of the afternoon was spent tidying up the routines to make them more modular (for instance, rather than have a routine to read the keyboard then adjust the scroll position, the keyboard routine merely set flags which are then used by the game engine to set other flags which drive the scroller). It also allows me to "detach" control of the scroller from the player's ship, for reasons which will become apparent much later. ;)

One thing that became apparent was the ugly nature of the 800x600 resolution - 64x64 blocks don't sit neatly within the screen any more, which looks a little messy on occasion. I've made a mental note to address this by using a Viewport, which will allow me to render the map inside a 768x576 window within the actual 800x600 screen; this will not only neaten up the tile layout, but will also give me a small black border around the playing area which will compliment the HUD very nicely indeed.

The day was rounded off by a little tweaking and bug fixing. There are a couple of quirks in the control routine at present, which causes Monitor's position to jump alarmingly near the edges of the map, and I still have to implement the collision detection, but these tasks are better tackled after a night's sleep. :)